Advertisement
Dj_Dexter

pomf

Oct 26th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.24 KB | None | 0 0
  1. #!/bin/bash
  2. # scrot -> pomf.se, by @__akiaki
  3. # little modified by Dj_Dexter, don't like take scrot and upload this!
  4. # don't delete the .png or another
  5. # and ok :)
  6.  
  7. FILE=$1
  8.  
  9. # take the shot
  10. #if [ "`uname`" == "Darwin" ]; then
  11. #    # assume Darwin is Mac OS X. Sorry, Darwin guys.
  12. #    FILE="$HOME/Desktop/scrotpomf-$(date '+%Y%m%d%H%M%S').png"
  13. #    screencapture ${SCROTARGS[@]} "${FILE}"
  14. #else
  15. #    FILE="`scrot ${SCROTARGS[@]} -e 'echo -n $f'`"
  16. #fi
  17.  
  18. # upload it and grab the URL
  19. BASE=""; TRY=0
  20. while [ "x$BASE" == "x" ] && [ $TRY -lt 3 ]; do
  21.     TRY=$[$TRY + 1]
  22.     echo "Uploading... (try $TRY)"
  23.     JSON="`curl -sf -F "files[]=@$FILE" http://pomf.se/upload.php`"
  24.     BASE="`echo "$JSON" | python -c "from __future__ import print_function;print(__import__('json').loads(__import__('sys').stdin.read())['files'][0]['url'])" 2>/dev/null`"
  25. done
  26.  
  27. if [ $TRY -eq 3 ]; then
  28.     echo "Giving up."
  29.     exit 1
  30. fi
  31.  
  32. URL="http://a.pomf.se/$BASE"
  33.  
  34. # copy the URL to the clipboard
  35. if [[ `type -p xclip` ]]; then
  36.     echo -n "$URL" | xclip -selection clipboard
  37.     echo "$URL (has been copied to clipboard)"
  38. elif [[ `type -p pbcopy` ]]; then
  39.     echo -n "$URL" | pbcopy
  40.     echo "$URL (has been copied to clipboard)"
  41. else
  42.     echo "$URL"
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement