Skip to content

Instantly share code, notes, and snippets.

@vibragiel vibragiel/screenshare
Last active Sep 9, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.