Dropbox Tip #2 – Sharing screenshots fast on Ubuntu

If you, like me, often send screenshots to your buddies so they can check out things you are working on, this is a very cool way to use dropbox and make very quick screenshots.

In a nutshell, we will replace the default Ubuntu printscreen feature with something else that does this:

a) Creates screenshot of whole desktop and saves it to you dropbox public folder without any prompts or user intervention.

b) Copies the dropbox public url of the new screenshot into your clipboard ready for speedy pasting into your irc or instant chat windows (or whereever else youd like to paste it).

Ok so its only saving a bit of mouse action and a rightclick or two but its pure command line and means you dont even need to leave the keyboard (that is cool by the way!)

Install Additional Apps

First we need to install two very tiny but very cool command line apps

sudo apt-get install xclip scrot

Setup Dropbox Public Folder for your Screenshots
(I am assuming you have dropbox setup already, if not get it here)

mkdir ~/Dropbox/Public/Screenshots

Setup New Screenshot Super Duper Script

You can create this script anywhere but i like to make sure all my scripts are available on all my linux machines so I have a bin folder in dropbox which is added to my bash path (how to share your bash scripts on all your pcs with Dropbox)

nano ~/Dropbox/bin/dropshot.sh

Paste the following into the nano window:

# 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/[put your id in here]/Screenshots/'

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

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

Make sure that script is executable with

chmod +x ~/Dropbox/bin/dropshot.sh

At this point i would run the script to check its working


Note: If this doesnt work make sure your dropbox bin folder is in your bashrc path variable (see guide above on how to make your scripts accessible on all your machines).

Once you’ve run  this just check your dropbox screenshots folder there should be a dated file in there. Id also goto a browser and paste the url (which should be nicely saved into your clipboard) into the address bar, if that also works then you are nearly there.

Note of xlip and scrot: Both of these little tools are great and very flexible, ive only used the basics here to keep it simple but check out the man pages there is loads you can do with them both.

Assign new screenshot  script to a keyboard shortcut

To finish this off nicely, you want to be able to run your new dropshot script by pressing a shortcut key.

For some reason i cannot map the default printscreen key either through the Preferences>Keyboard Shortcuts tool OR via gconf-editor so for now ive mapped it to ALT-F12 but choose whatever key you want.

Now if you are chatting to a friend and you want to send them a screenshot you just do Alt-F12 then Ctrl-V, thats it. No need to even take your hands off the keyboard.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s