Skip to content

Instantly share code, notes, and snippets.

@Cewlt
Last active August 31, 2016 16:33
Show Gist options
  • Save Cewlt/ad6314ed7e3800d6db50 to your computer and use it in GitHub Desktop.
Save Cewlt/ad6314ed7e3800d6db50 to your computer and use it in GitHub Desktop.
bash screenshot script using imgur api, appended with key shortcut
clientid='<insert imgur client id here>'
img=$(mktemp '/tmp/img-XXXXXX.png')
gnome-screenshot -a -f $img >/dev/null 2>&1 || exit
res=$(curl -sH "Authorization: Client-ID $clientid" -F "image=@$img" "https://api.imgur.com/3/upload")
echo $res | grep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
test -n "$link" && (x-www-browser $link && rm "$img") || echo "$res" > "$img.error"
notify-send "screenshot successful!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment