Made selections optional--full screen is now the default.

master
Ceryn 2014-02-20 13:13:58 +01:00
parent d829a6b5a5
commit 9aec432ba8
2 changed files with 10 additions and 2 deletions

7
README
View File

@ -6,3 +6,10 @@ On failure, it writes the curl output to /tmp/, where the image is also stored.
No output is produced.
img depends on scrot, curl and xclip.
You can use the following command to check dependencies:
for p in scrot curl xclip; do test $(command -v $p) && echo "Ok $p" || echo "No $p"; done
Recommended usage: Bind a key (such as PrtSc) to execute the script easily.
Note: If you are using dwm, you will need to use the following patch for
screen selections: http://dwm.suckless.org/patches/keypressrelease.

5
img.sh
View File

@ -1,11 +1,12 @@
#!/bin/bash
# https://github.com/Ceryn/img
# Call with '-s' to target only a selection of the screen.
clientid='3e7a4deb7ac67da'
img=$(date '+/tmp/%N.png')
scrot -zs $img >/dev/null 2>&1 || exit
scrot -z "$@" $img >/dev/null 2>&1 || exit
res=$(curl -sH "Authorization: Client-ID $clientid" -F "image=@$img" "https://api.imgur.com/3/upload")
echo $res | egrep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
echo $res | grep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
test -n "$link" && (printf $link | xclip; printf "\a") || echo "$res" > "$img.error"