├── README.md ├── icon.png └── puush /README.md: -------------------------------------------------------------------------------- 1 | Puush in Linux 2 | ===================== 3 | 4 | Takes screenshots and uploads them to puush using the puush API and copies the link to clipboard. Recommended for set up with keyboard shortcuts 5 |
Utilises __gnome-screenshot__ for taking screenshots, __zenity__ for file uploads (both included in Ubuntu). 6 | 7 | ## Instructions 8 | - Clone or download the repo 9 | - In file "puush" add your puush API key to PUUSH_API_KEY 10 | - (You can find your API key at http://puush.me/account/settings) 11 | - Make it executable using __chmod +x puush__ 12 | - Place this file wherever you want (recommended: /usr/local/bin) 13 | - Set up keyboard shortcuts within linux 14 | - (in Ubuntu it's system settings > keyboard > keyboard shortcuts > custom shortcuts) 15 | - Log out for the changes to take place 16 | - Here's what it looks like for mine: ![Puush keyboard setup](http://puu.sh/cOyVz/8dcb1cd498.png) 17 | 18 | ### Commands 19 | ``` bash 20 | puush -a # puush desktop 21 | puush -b # area puush 22 | puush -c # puush window 23 | puush -d # file upload 24 | 25 | puush -h # help 26 | ``` 27 | 28 | ## Dependencies 29 | - gnome-screenshot 30 | - zenity 31 | - curl 32 | - xclip 33 | - notify-send 34 | 35 | 36 | ### Alternatives 37 | - puush in command line https://github.com/blha303/puush-linux 38 | - puush using keyboard https://github.com/sgoo/puush-linux 39 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunmockyang/puush-linux/f4155239dbc9268bbf7ca16173c873bda19d85f1/icon.png -------------------------------------------------------------------------------- /puush: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set API Key here 3 | PUUSH_API_KEY="" 4 | 5 | # Puush for Ubuntu/linux 6 | # Owner : Sunmock Yang 7 | # www.sunmock.com 8 | # May 2014 9 | # 10 | # Dependencies: 11 | # - gnome-screenshot 12 | # - curl 13 | # - zenity 14 | # - xclip 15 | # - notify-send 16 | # 17 | # Licence : Beerware 18 | # 19 | # Instructions: 20 | # - Add your puush API key to PUUSH_API_KEY (You can find your API key at http://puush.me/account/settings) 21 | # - Place this file wherever you want (/usr/local/bin) 22 | # - Set up keyboard shortcuts within linux (in Ubuntu it's system settings > keyboard > keyboard shortcuts > custom shortcuts) 23 | # 24 | # command description (recommended keyboard shortcut) 25 | # --------------------------------------------------------------- 26 | # puush -c puush window (Ctrl + Shift + 2/@) 27 | # puush -a puush desktop (Ctrl + Shift + 3/#) 28 | # puush -b area puush (Ctrl + Shift + 4/$) 29 | # puush -d file upload (Ctrl + Shift + U) 30 | # puush -e puush clipboard (Ctrl + Shift + 1/!) 31 | # 32 | # 33 | # Notes: 34 | # - Link(s) will be copied into clipboard and appear in notifications 35 | # - puush curl upload code borrowed from online sources 36 | 37 | # Usage: puushFile [fileName] 38 | function puushFile () 39 | { 40 | if [ -z "$1" ]; then 41 | echo "No file specified" 42 | exit 1 43 | elif [ ! -f "$1" ]; then 44 | echo "Puush cancelled" 45 | exit 1 46 | fi 47 | 48 | fileURL=`curl "https://puush.me/api/up" -# -F "k=$PUUSH_API_KEY" -F "z=waifu" -F "f=@$1" | sed -E 's/^.+,(.+),.+,.+$/\1\n/'` 49 | 50 | if [ ! -z "$fileURL" ]; then 51 | #Copy link to clipboard, show notification 52 | printf $fileURL | xclip -selection "clipboard" 53 | notify-send -i "$( cd "$( dirname "$0" )" && pwd )/icon.png" -t 2000 "puush complete!" "$fileURL" 54 | fi 55 | } 56 | 57 | function helpText () 58 | { 59 | printf "_____________ puush for linux _____________\n" 60 | printf "Created by Sunmock Yang using the puush api\n" 61 | printf "\n" 62 | printf "Usage:\n" 63 | printf " puush [OPTIONS] [PATH]\n" 64 | printf "\n" 65 | printf "OPTIONS:\n" 66 | printf " -a puush entire desktop\n" 67 | printf " -b select area to puush\n" 68 | printf " -c puush current window\n" 69 | printf " -d puush specific file (opens file dialog)\n" 70 | printf " -e puush clipboard contents\n" 71 | printf "\n" 72 | printf " --help,-h show this page\n" 73 | printf "\n" 74 | printf "PATH:\n" 75 | printf " PATH optional: path of file to puush\n" 76 | } 77 | 78 | function generateFileName () { echo "/tmp/puush-linux ($(date +"%Y-%m-%d at %I.%M.%S")).png"; } 79 | 80 | 81 | if [ -z "$PUUSH_API_KEY" ]; then 82 | echo "Set the variable PUUSH_API_KEY in $0" 83 | echo "You can find your API key at http://puush.me/account/settings" 84 | 85 | notify-send -i "$( cd "$( dirname "$0" )" && pwd )/icon.png" "Set the variable PUUSH_API_KEY in $0" "You can find your API key at http://puush.me/account/settings" 86 | 87 | exit 1 88 | 89 | elif [ -z "$1" ]; then 90 | echo "No file entered." 91 | helpText 92 | exit 1 93 | 94 | fi 95 | 96 | #Get file to puush and puush it 97 | case "$1" in 98 | -a) 99 | echo "Whole Desktop" 100 | fileName=$(generateFileName) 101 | gnome-screenshot -f "$fileName" 102 | puushFile "$fileName" 103 | ;; 104 | 105 | -b) 106 | echo "Area" 107 | fileName=$(generateFileName) 108 | gnome-screenshot -a -f "$fileName" 109 | puushFile "$fileName" 110 | ;; 111 | 112 | -c) 113 | echo "Window" 114 | fileName=$(generateFileName) 115 | gnome-screenshot -w -f "$fileName" 116 | puushFile "$fileName" 117 | ;; 118 | 119 | -d) 120 | echo "File Upload" 121 | fileName=`zenity --file-selection` 122 | puushFile "$fileName" 123 | ;; 124 | 125 | -e) 126 | echo "Clipboard Upload" 127 | targets=`xclip -selection clipboard -t TARGETS -o` 128 | fileName="/tmp/puush-linux-clip" 129 | 130 | for target in $targets 131 | do 132 | if [[ "$target" =~ "/" ]]; then 133 | xclip -selection "clipboard" -t "$target" -o > "$fileName" 134 | puushFile "$fileName" 135 | exit $? 136 | fi 137 | done 138 | 139 | # we're here because clipboard content's MIME-type is not really known. Does it even have a type? 140 | # well, let's hope for the best and push it as plaintext 141 | 142 | xclip -selection "clipboard" -t "text/plain" -o > "$fileName" 143 | puushFile "$fileName" 144 | ;; 145 | 146 | -h|--help) 147 | helpText 148 | exit 0 149 | ;; 150 | 151 | *) 152 | echo "Upload $1" 153 | puushFile "$1" 154 | ;; 155 | 156 | esac 157 | --------------------------------------------------------------------------------