Created
March 29, 2011 14:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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