Skip to content

Instantly share code, notes, and snippets.

@vibragiel
Last active September 9, 2015 11:13
Show Gist options
  • Save vibragiel/80791ed5feef748de9f8 to your computer and use it in GitHub Desktop.
Save vibragiel/80791ed5feef748de9f8 to your computer and use it in GitHub Desktop.
Script to grab a screenshot, put it in a Dropbox directory and copy its public link into the clipboard. Modified from https://gist.github.com/Saicheg/4231551
#!/bin/bash
# Usage: screenshare [-m <window|area|desktop>] [-d <integer>] [-p]
# -m window Grab active window
# -m area Grab an area selected with the mouse
# -m desktop Grab whole desktop
# -d <integer> Grab after the specified delay in seconds
# -p Include mouse pointer in the screenshot
# Description: Take a screenshot, store it in Dropbox and copy public link
# into the clipboard
# Author: Gabriel Rodríguez Alberich
# License: MIT
# Requirements: Dropbox, gnome-screenshot, xclip
# Notes: Please ensure that ~/Dropbox/Public/screenshots/ exists
# You might want to reassign your desktop keybindings to call
# this script. For example:
# 'Print' -> screenshare
# '<Shift>Print' -> screenshare -m area
# '<Alt>Print' -> screenshare -m window
usage() { echo "Usage: $0 [-m <window|area|desktop>] [-d <integer>] [-p]" 1>&2; exit 1; }
mode= delay= opts=
while getopts m:d:p opt; do
case ${opt} in
m)
mode=${OPTARG}
case ${mode} in
window)
opts="$opts --window"
;;
area)
opts="$opts --area"
;;
desktop)
;;
*)
usage
;;
esac
;;
d)
delay=${OPTARG}
if [[ $delay =~ ^[0-9]+$ ]]; then
opts="$opts --delay=$delay"
else
usage
fi
;;
p)
opts="$opts --include-pointer"
;;
*)
usage
;;
esac
done
shift $((OPTIND - 1))
TSTAMP=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
IMAGEPATH=~/Dropbox/Public/screenshots/Screenshot-$TSTAMP.png
gnome-screenshot -f $IMAGEPATH $opts
dropbox puburl $IMAGEPATH | xclip -selection c
notify-send "Screenshare" "Screenshot saved to $IMAGEPATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment