change igm2clip scripts to good old bash
This commit is contained in:
@@ -1,20 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
import pygtk,gtk,os,sys
|
||||
pygtk.require('2.0')
|
||||
from argparse import ArgumentParser
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo -e ' Copy image to clipboard
|
||||
|
||||
def copy_image(f):
|
||||
assert os.path.exists(f), "file does not exist"
|
||||
image = gtk.gdk.pixbuf_new_from_file(f)
|
||||
Usage: img2clip path-to-image
|
||||
'
|
||||
}
|
||||
|
||||
clipboard = gtk.clipboard_get()
|
||||
clipboard.set_image(image)
|
||||
clipboard.store()
|
||||
while getopts h opt
|
||||
do case "$opt" in
|
||||
h)
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ -z "$1" ]]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
parser=ArgumentParser(description="Copy image to clipboard.")
|
||||
parser.add_argument('image', action="store")
|
||||
opts=parser.parse_args()
|
||||
mime=$( file -b --mime-type "$1" )
|
||||
xclip -selection primary -t "$mime" -i "$1"
|
||||
xclip -selection clipboard -t "$mime" -i "$1"
|
||||
|
||||
|
||||
copy_image(opts.image);
|
||||
|
||||
Reference in New Issue
Block a user