Full-time developer on a small team. Writing great specs and code, delivered on time. Chase is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. You can read more from them at their website. View Full User Profile

Save a screenshot to Dropbox with a keyboard shortcut

05.19.2012
| 1390 views |
  • submit to reddit

It's not uncommon for me to call my product manager over to my desk half a dozen times on a given day to look at what I'm working on. To speed things up, I decided to start IMing him screen shots instead. Here is a BASH script that builds on Drjnet's excellent script, but which also allows you to select just a small region of your screen to capture.

#!/bin/bash

# Setup filename for the screenshot
myfile=$(date +%Y%m%d%S).png

#Setup paths to dropbox & full url to new screenshot
dropboxwebpath='http://dl.dropbox.com/u/422013/temp/' # PUT YOUR DROPBOX USERID HERE
dropboxfileurl=$dropboxwebpath$myfile

# see: http://code.google.com/p/xmonad/issues/detail?id=476
sleep 0.2

# Use scrot to take a screenshot and stick it in your dropbox screenshots folder
scrot $myfile -e 'mv $f ~/Dropbox/Public/temp/' -s

#  Put full URL to new screenshot into clipboard
echo $dropboxfileurl | xclip -selection c

Note the sleep; that's important to get around a race condition between scrot and your window manager for access to your mouse/keyboard.

To install as a keyboard shortcut (I have mine bound to Windows + PrtScr), just launch the "Keyboard" app in Ubuntu, and add it under Shortcuts -> Custom Shortcuts.

Published at DZone with permission of Chase Seibert, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: