Share the Knowledge!

These scripts are useful to share screenshots of your computer with anyone using the benefits of your Dropbox Public folder.

Bash script

This is the most simple script that will do the job for Linux users. First idea was published to the forums by Mark G.

Just change the  DBUSER variable to match you Dropbox UID. All your public links are like http://dl.dropbox.com/u/your_dropbox_UID/path_to_requested_file, so you can find your UID just checking one of your public links.

# Change DBUSER to match your Dropbox UID. For more intstructions, see above.
DBUSER=CHANGEME
TIME=$(date +%Y%m%d%H%M%S)
PUB=~/Dropbox/Public/screenshots/
if [ -d $PUB ]
then
cd $PUB
else
mkdir $PUB
cd $PUB
fi
sleep 1
scrot -d 5 -q 100 $TIME.jpg
sleep 1
LAST=$(find . -cmin -1 -iname "*.jpg" | tail -n 1 | sed 's!.*/!!')
URL1=http://dl.dropbox.com/u
URL2=screenshots
echo "$URL1/$DBUSER/$URL2/$LAST" | xclip -sel clip
exit 0

Bash script with bit.ly

Same than last one, but shorts the URL after saving the screenshot. Also posted by Mark G. to the forums.

You will need an account to bit.ly to get short URLs. Remember to change DBUSER, BITLYUSER and BITLYKEY before using it.

DBUSER=CHANGEME
BITLYUSER=CHANGEME2
BITLYKEY=CHANGEME3
TIME=$(date +%Y%m%d%H%M%S)
DBDIR1=~/Dropbox/Public
SSDIR2=screenshots
TMP=~/.bigurl
if [ -d $DBDIR1/$SSDIR2 ]
then
        cd $DBDIR1/$SSDIR2
else
        mkdir $DBDIR1/$SSDIR2
        cd $DBDIR1/$SSDIR2
fi
scrot -d 5 -q 100 $TIME.jpg
echo "http://dl.dropbox.com/u/$DBUSER/$SSDIR2/$(find . -cmin -1 -iname "*.jpg" | tail -n 1 | sed 's!.*/!!')" > $TMP
echo "$(cat $TMP | sed 's,:,%3A,g;s,/,%2F,g')" > $TMP
echo "http://api.bit.ly/v3/shorten?login=$BITLYUSER&apiKey=$BITLYKEY&longUrl=$(cat $TMP)&format=txt" > $TMP
curl -s -S $(cat $TMP) | xclip -sel clip
rm $TMP
exit 0

Dropbox Screen Grabber

Dropbox Screen Grabber is a simple application which sits in the system tray and allows you to capture the screenshot of the whole desktop or the currently active window and save it to the Dropbox public folder.

If you specify your Dropbox user ID in the settings, application can also automatically copy your public file URL to the clipboard after taking the screenshot.

More information available at its wiki page.

Multiplatform python script

This script works both in Windows and Linux systems, allowing you to get a Dropbox short URL like http://db.tt/<code>. It uses PyGTK or PyQt4 libs, depending on the environment, to take the screenshots.

Usually you will be able to run this script without installing anything in most popular Linux distributions (tested with Ubuntu and Kubuntu).

Windows users must have Python 2.x and the library PyGTK, both available in a nice autoinstallable format.

There are different options to run this script. The first one assumes you use default settings for your Dropbox and you want to store screenshots in a subfolder named Screenshots. If this is you case, you just need to download the script and run (Start/Run or command line):

  •  python screenshot.py your_dropbox_UID [seconds_to_wait], or
  •  python screenshot.py your_dropbox_email your_dropbox_password [seconds_to_wait]

while python must be the correct path to your Python executable (c:\python27\python.exe by default in Windows) and screenshot-full.py the path to your script.

You can create a link to this command and put it to you taskbar or your menu to access it easily.

Both ways will wait the time you indicated, take a screenshot, save it to your Dropbox/Public folder and copy the public link to the clipboard, so you will be able to share it with anyone via instant messaging or mail.

The second one, will also retrieve and copy to your clipboard a short link of the image via Dropbox shortern URL. At the moment, it’s not possible to get a short link without having access to your Dropbox credentials and the API is not offering that, so this script uses direct HTTP requests.

If you need to change some parameters of the script (for example if you don’t want to enter your UID or your Dropbox credentials everytime), you can always edit the first lines of the file and customize it.

Downloads

(Download links are unavailable) This tool is made of two modules:

  • screenshot.py, is the main file
  • dropbox.py, is a class able to login into Dropbox and retrieve HTML pages using your cookies

Once downloaded both files and stored together at the same folder, you will need to run screenshot.py to take the screenshot.

It’s not necessary to download the file dropbox.py if you plan to use long URLs.

Share the Knowledge!

  • Ali Ayoub

    screenshot.py and dropbox.py links are broken. Can you please fix them?

  • so … what do we do with those Bash scripts?