Skip to content

Instantly share code, notes, and snippets.

@treyhunner
Created March 29, 2011 14:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treyhunner/892492 to your computer and use it in GitHub Desktop.
Save treyhunner/892492 to your computer and use it in GitHub Desktop.
Grab a screenshot, give it a public dropbox URL, shorten the URL, and copy it to the clipboard
#!/bin/sh
# Ubuntu-specific modification of http://wiki.dropbox.com/TipsAndTricks/ShareScreenshots
# Change these
DB_USER_ID=YOURDBUSERID
BITLY_USERNAME=YOURBITLYUSERNAME
BITLY_API_KEY=YOURBITLYKEYHERE
DROPBOX_PUBLIC_DIR=~/Dropbox/Public
SCREENSHOT_DIR=screenshots
CAPTURE_DELAY=0
PICTURE_QUALITY=50
FILE_EXTENSION=png
TIME=$(date +%Y%m%d%H%M%S)
FILENAME=$TIME.$FILE_EXTENSION
# Move to the directory where screenshots will be stored
mkdir -p $DROPBOX_PUBLIC_DIR/$SCREENSHOT_DIR
cd $DROPBOX_PUBLIC_DIR/$SCREENSHOT_DIR
# Take screenshot and save in screenshot directory
scrot -d $CAPTURE_DELAY -q $PICTURE_QUALITY $FILENAME
# Get Dropbox public URL for screenshot
DB_URL="http://dl.dropbox.com/u/$DB_USER_ID/$SCREENSHOT_DIR/$FILENAME"
# Get bit.ly shortened URL for Dropbox URL
ESCAPED_DB_URL="$(echo $DB_URL | sed 's,:,%3A,g;s,/,%2F,g')"
BITLY_API_CALL="http://api.bit.ly/v3/shorten?login=$BITLY_USERNAME&apiKey=$BITLY_API_KEY&longUrl=$ESCAPED_DB_URL&format=txt"
SHORT_URL=$(curl -s -S $BITLY_API_CALL)
# Copy shortened URL to clipboard
echo $SHORT_URL | xclip -sel clip
# Display message to user (requires libnotify)
notify-send "Screenshot added" "Screenshot link copied to clipboard: $SHORT_URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment