change igm2clip scripts to good old bash
This commit is contained in:
@@ -1,33 +1,24 @@
|
|||||||
#!/usr/bin/env python
|
#!/bin/bash
|
||||||
import pygtk,gtk,os,sys
|
|
||||||
pygtk.require('2.0')
|
|
||||||
from argparse import ArgumentParser
|
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo -e ' Copy clipboard to image
|
||||||
|
|
||||||
def write_image(f):
|
Usage: clip2img path-to-image
|
||||||
|
'
|
||||||
clipboard = gtk.clipboard_get()
|
}
|
||||||
image = clipboard.wait_for_image()
|
|
||||||
if image==None:
|
|
||||||
sys.stderr.write("No image in clipboard!\n")
|
|
||||||
sys.exit(1)
|
|
||||||
image.save(f, type_str(f))
|
|
||||||
|
|
||||||
def type_str(f):
|
while getopts h opt
|
||||||
filename, file_extension = os.path.splitext(f.lower())
|
do case "$opt" in
|
||||||
file_extension=file_extension[1:]
|
h)
|
||||||
if file_extension=="jpg":
|
usage
|
||||||
return 'jpeg'
|
exit
|
||||||
if file_extension=="tif":
|
;;
|
||||||
return 'tiff'
|
esac
|
||||||
|
done
|
||||||
return file_extension
|
if [[ -z "$1" ]]; then
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
parser=ArgumentParser(description="Write image from clipboard to image file. Extension jpg/png/tif/ico/bmp.")
|
xclip -selection clipboard -o | convert - "$1"
|
||||||
parser.add_argument('image', action="store")
|
|
||||||
opts=parser.parse_args()
|
|
||||||
|
|
||||||
if (os.path.exists(opts.image)):
|
|
||||||
sys.stderr.write("Image already exists!\n")
|
|
||||||
sys.exit(1)
|
|
||||||
write_image(opts.image);
|
|
||||||
|
|||||||
@@ -1,20 +1,26 @@
|
|||||||
#!/usr/bin/env python
|
#!/bin/bash
|
||||||
import pygtk,gtk,os,sys
|
|
||||||
pygtk.require('2.0')
|
|
||||||
from argparse import ArgumentParser
|
|
||||||
|
|
||||||
|
function usage {
|
||||||
|
echo -e ' Copy image to clipboard
|
||||||
|
|
||||||
def copy_image(f):
|
Usage: img2clip path-to-image
|
||||||
assert os.path.exists(f), "file does not exist"
|
'
|
||||||
image = gtk.gdk.pixbuf_new_from_file(f)
|
}
|
||||||
|
|
||||||
clipboard = gtk.clipboard_get()
|
while getopts h opt
|
||||||
clipboard.set_image(image)
|
do case "$opt" in
|
||||||
clipboard.store()
|
h)
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
usage
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
parser=ArgumentParser(description="Copy image to clipboard.")
|
mime=$( file -b --mime-type "$1" )
|
||||||
parser.add_argument('image', action="store")
|
xclip -selection primary -t "$mime" -i "$1"
|
||||||
opts=parser.parse_args()
|
xclip -selection clipboard -t "$mime" -i "$1"
|
||||||
|
|
||||||
|
|
||||||
copy_image(opts.image);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user