Advertisement
Tomin

scrottaa.sh

Dec 25th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #!/bin/sh
  2. # This script is made by Tomi Leppänen aka Tomin (http://tomin.dy.fi/)
  3. # You are free to use, copy, redistribute and modify this script
  4. # as long as you accept that ***I won't take any responsibility
  5. # for this code and it comes without any warranty***
  6.  
  7. # This script takes a screenshot from the part of screen that you can
  8. # select by mouse and then it saves the screenshot to your Dropbox
  9. # folder and then pastes a public link to clipboard.
  10.  
  11. # It is recommended to add this as a hotkey to your DE
  12.  
  13. # Configuration:
  14. # Date format
  15. DATE=`date +%Y-%m-%d-%H-%M-%S`
  16. # Directory to save images
  17. DIRECTORY="$HOME/Dropbox/Public/Scrot"
  18. # Clipboard to use, values: 'clipboard' for keyboard,
  19. #        and 'primary' for mouse-middle-click
  20. #        or 'both' for both of them
  21. CLIPBOARD='primary'
  22.  
  23. # Check depenciens
  24. if [ -z `which scrot` 2> /dev/null ]
  25.     then echo "Scrot is requred! Install scrot"
  26.     exit
  27. fi
  28. if [ -z `which xclip` 2> /dev/null ]
  29.     then echo "Xclip is required! Install xclip"
  30.     exit
  31. fi
  32. if [ -z `which dropbox` 2> /dev/null ]
  33.     then echo "Dropbox is required! Install dropbox"
  34.     exit
  35. fi
  36.  
  37. # The code
  38. URL_PREFIX="http://dl.dropbox.com/u/$USERID/$DIRECTORY"
  39. scrot -s "$DIRECTORY/$DATE.png"
  40. PUBURL=$(dropbox puburl "$DIRECTORY/$DATE.png" |tr -d "\n")
  41. if [ $CLIPBOARD == "both" ]; then
  42.     echo -n "$PUBURL" |xclip -selection clipboard
  43.     echo -n "$PUBURL" |xclip -selection primary
  44. else
  45.     echo -n "$PUBURL" |xclip -selection $CLIPBOARD
  46. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement