Last active
August 29, 2015 14:14
-
-
Save johnl/0febba385e36c3dc2034 to your computer and use it in GitHub Desktop.
Screenshot taker/uploader
This file contains hidden or 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 | |
# Takes a screenshot, uploads via scp, puts url on the clipboard | |
# Edit the code to set the scp destination and url format | |
# | |
# Bind it to a gnome keyboard shortcut for speedy screen sharing | |
# | |
# Ridiculously this needs bash, gnome-screenshot, xclip, scp, notify-send, sha256sum AND Ruby | |
set -e | |
TMPFILE="/dev/shm/screenshot-${USER}-`date +"%s"`.png" | |
# Weirly need to sleep here due to some timing problem when | |
# executing this as a keyboard shortcut in gnome | |
sleep 0.1 | |
gnome-screenshot --file=$TMPFILE --area 2>>${HOME}/screenshot.log | |
if [ ! -e $TMPFILE ] ; then | |
exit 0 | |
fi | |
echo $TMPFILE | |
CSUM=`sha256sum $TMPFILE | ruby -e 'puts STDIN.read.to_i(16).to_s(36)'` | |
echo $CSUM | |
FILENAME=`date +%Y%m%d`-${CSUM}.png | |
URL=http://johnleach.co.uk/scrot/${FILENAME} | |
echo -e "`date`:\t$TMPFILE\t$URL" >> ${HOME}/screenshot.log | |
echo -n $URL | xclip -selection c | |
echo "Copying up to server" | |
scp $TMPFILE [email protected]:johnleach.co.uk/scrot/${FILENAME} && | |
/usr/bin/notify-send -t 2000 -u low "Screenshot uploaded successfully" && | |
rm $TMPFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment