Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created March 8, 2012 21:46
Show Gist options
  • Save robertbasic/2003671 to your computer and use it in GitHub Desktop.
Save robertbasic/2003671 to your computer and use it in GitHub Desktop.
xfce4-screenshooter to imgur
#!/bin/bash
function rename_file()
{
NEWFILE=$(echo $1 | md5sum | cut -c-5)'.png'
}
API_KEY=PUT_YOUR_IMGUR_API_KEY_HERE
URL=http://api.imgur.com/2/upload
LOCALPATH=/path/to/screenshots/
xfce4-screenshooter -r --save=$LOCALPATH
LOCALFILE=$(ls -tr $LOCALPATH | tail -n 1)
rename_file $LOCALFILE
I=0
LIMIT=10
while [ "$I" -lt "$LIMIT" -a -f "$LOCALPATH$NEWFILE" ]
do
rename_file $NEWFILE
I=`expr $I + 1`
done
mv "$LOCALPATH$LOCALFILE" "$LOCALPATH$NEWFILE"
RESPONSE=$(curl -s -F "key=$API_KEY" -F "image=@$LOCALPATH$NEWFILE" $URL)
echo "$RESPONSE" | grep -o -E "<original>.*</original>" | grep -o -E "http://.*\.png" | xclip -selection clipboard
notify-send "Screenshot uploaded, URL in clipboard"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment