Last active
December 15, 2015 20:29
-
-
Save jianingy/5318784 to your computer and use it in GitHub Desktop.
do a screenshot using scrot and upload it to imgur.com. Of course, the image link will be in clipboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# filename : screenshot.sh | |
# created at : 2013-04-05 20:01:35 | |
# author : Jianing Yang <jianingy.yang AT gmail DOT com> | |
# client id from imgur.com | |
client=0350033e1d023ba | |
# temporary file for storing screenshot | |
img=$(mktemp --suffix .png) | |
trap "rm $img" EXIT | |
# shot. use import from imagemagick as scrot has some keybinding problem | |
import $img || exit 1 | |
# upload | |
link=$(curl -s -X POST -H "Authorization: Client-ID $client" -F "image=@$img" https://api.imgur.com/3/upload.xml | grep -oE '<link>([^<]+)</link>' | sed 's#</\?link>##g') | |
[ -z "$link" ] && echo 'upload failed!' && exit | |
# save link in clipboard | |
(echo $link | xclip -in) || exit 1 | |
notify-send "screenshot saved at $link" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment