Imgur bash script won't work when bound to a key
I've slightly modified the official Imgur uploading script to allow for it to be bound to a key, however when I actually press the key, it seems to just run the two notify-send commands and end the script. It works if I execute through terminal or through ALT+F2, but not through the keypress no matter what I use.
The script is as follows:
#!/bin/bash
sleep 0.5;
notify-send "Imgur Uploader";
function uploadImage {
curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" http://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | gr开发者_开发技巧ep -E -o "http://i.stack.imgur.com/[^<]*";
}
scrot -s "shot.png";
image=`uploadImage "shot.png"`;
echo $image | xclip -selection c;
rm "shot.png";
notify-send "Done!" "$image";
Like I said, the script works when called manually, but I can't get it running bound to a keypress. I've tried screenshot
, /usr/bin/screenshot
, sh screenshot
and sh /usr/bin/screenshot
among others. Am I missing something major here?
Most likely, the script is running with its current directory set to /usr/bin
.
Try adding the following to the beginning of the script:
cd /tmp
精彩评论