Skip to content

Instantly share code, notes, and snippets.

@senko
Created August 28, 2012 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senko/3505177 to your computer and use it in GitHub Desktop.
Save senko/3505177 to your computer and use it in GitHub Desktop.
Grab a screenshot and paste it to the Web
#!/bin/bash
#
# screen-paste - Paste a screenshot to the Web
#
# Written by Senko Rasic <senko.rasic@goodcode.io>
# Released into Public Domain. Use it as you like.
#
# The tool allows the user to select a portion of the screen, then copies it
# to S3, and stores the resulting URL in clipboard.
#
# Requirements: uuidgen, scrot, s3cmd, xclip, mplayer (optional)
S3_DESTINATION="s3://dobarkod.hr-test/screenshots/"
SHUTTER_SOUND="/usr/share/sounds/freedesktop/stereo/camera-shutter.oga"
set -ex
fname="/tmp/$(uuidgen).png"
test -f "$fname" && rm -f "$fname"
scrot -z -s "$fname"
s3cmd put -P --no-progress "$fname" "$S3_DESTINATION" | \
grep '^Public URL' | \
sed s'/.*: //' | \
xclip -i -selection "clipboard"
rm -f "$fname"
if $(which mplayer) && test -f "$SHUTTER_SOUND"; then
mplayer -really-quiet "$SHUTTER_SOUND" >/dev/null 2>&1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment