Want more features on Pastebin? Sign Up, it's FREE!
Guest

screenie patch

By: a guest on Jul 4th, 2010  |  syntax: Bash  |  size: 2.12 KB  |  views: 81  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash -e
  2.  
  3. # screenie is a small script that is designed to instantly take a screenshot of your current desktop, upload the screenshot to the Internet, grab the file's URL and compact it down via the bit.ly (http://www.bit.ly) URL shortening service. There are three external commandline dependencies, programs which should be available in your distro's repositories:
  4. #
  5. #               1. curl, 2. scrot, and 3. xclip
  6. #
  7. # You are free to alter and redistrbute this script as you see fit, although I would ask that you leave this attribution in place. Any queries or comments should be send to my email: mark@bhalash.com or my Twitter account: @bhalash. If you don't already have Dropbox installed, you can get it (and help me out with more space!) through this link:
  8. #
  9. #               https://www.dropbox.com/referrals/NTQxNDQ5MTk5
  10. #
  11. # There are three very important variables that you *must* change:
  12. #
  13. #               1. DBUSER - your Dropbox user ID. You can acquire this by right-clicking on any item in your Public Dropbox folder and copying the public sharing link. The 7-digit string of numbers, $FOO, in "http://dl.dropbox.com/u/$FOO/file.jpg" is your UID.
  14. #               2.      BITLYUSER - Your bit.ly user name. This should be self-explanatory.
  15. #               3.      BITLYKEY - Your bit.ly API key. It can be found at http://bit.ly/a/account
  16.  
  17. DBUSER=CHANGEME1 # Your Dropbox UID.
  18. BITLYUSER=CHANGEME2 # Your bit.ly login name - comment out to disable URL shortening
  19. BITLYKEY=CHANGEME3 #Your bit.ly API key
  20.  
  21. TIME=$(date +%Y%m%d%H%M%S) # File name format is YYYYMMDDHHMMSS.jpg
  22. DBDIR1=~/Dropbox/Public # You shouldn't need to change this. Ever.
  23. SSDIR2=screenshots # Ditto. Just make sure it stays in your Public folder.
  24.  
  25. [ -d $DBDIR1/$SSDIR2 ] || mkdir $DBDIR1/$SSDIR2
  26. cd $DBDIR1/$SSDIR2
  27.  
  28. SSHOTFILE=$TIME.jpg
  29. DBURL="http://dl.dropbox.com/u/$DBUSER/$SSDIR2/$SSHOTFILE"
  30.  
  31. scrot -d 0 -q 100 $SSHOTFILE
  32.  
  33. [ -z "$BITLYUSER" ] && echo "$DBURL" | xclip -sel clip && exit 0
  34.  
  35. BITLYURL="http://api.bit.ly/v3/shorten"
  36. curl="curl -s -S -G $BITLYURL"
  37. params="-d login=$BITLYUSER -d apiKey=$BITLYKEY -d format=txt"
  38. params="$params --data-urlencode longUrl=$DBURL"
  39.  
  40. $curl $params | xclip -sel clip
  41.  
  42. exit $?
clone this paste RAW Paste Data