开发者

Imgur bash script won't work when bound to a key

开发者 https://www.devze.com 2023-03-04 03:33 出处:网络
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 s

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号