Skip to content

Instantly share code, notes, and snippets.

@tsaavik
Last active October 23, 2018 20:49
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 tsaavik/7103684 to your computer and use it in GitHub Desktop.
Save tsaavik/7103684 to your computer and use it in GitHub Desktop.
Automatically grabs a screenshot of a window after a short delay (default is 2 seconds),then copies it to /Dropbox/Public/share/Screenshots/hostname/and saves path to clipboard
#!/bin/bash
# sgrab - David Mcanulty 2013
#
# Inspried by gist: https://gist.github.com/Saicheg/4231551
# Automatically grabs a screenshot of a the currently active
# window after a short delay (default is 2 seconds), and
# then copies it to /Dropbox/Public/share/Screenshots/hostname/
# and saves a tiny url encoded path to your system's clipboard
#
# You can use any scrot switch to override the defaults, like --select
# To select and area of a window instead of the entire window.
#
# Requires:
# curl
# Dropbox
# scrot
# xclip
#################
dirpath="${HOME}/Dropbox/Public/share/Screenshots/$HOSTNAME"
delay=2
tstamp="$(date +%s)"
maketinyurl () {
url="$1"
curl --silent --output - "http://tinyurl.com/api-create.php?url=${url}"
}
mkdir -p "${dirpath}"
imagepath="${dirpath}/$tstamp.png"
if [[ -n $1 ]] ;then
scrot $@ "$imagepath"
else
scrot --delay ${delay} --focus "$imagepath"
fi
longurl=$(dropbox sharelink "$imagepath")
maketinyurl "${longurl}" | xclip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment