├── LICENSE ├── README.md ├── sxhkdrc └── uguush /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Joe Schillinger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uguush 2 | 3 | command-line uploader for various file hosts 4 | 5 | ![Usage](https://u.teknik.io/WldwN2.png) 6 | 7 | ## Usage 8 | 9 | uguush [options] 10 | 11 | Options: 12 | 13 | `-d` Delay the screenshot by the specified number of seconds. 14 | 15 | `-f` Take a fullscreen screenshot. 16 | 17 | `-h` Show this help message. 18 | 19 | `-o` Select a host to use. Can be uguu, teknik, 0x0, ptpb, mixtape, lewd, fiery or doko. 20 | 21 | `-p ` Custom path to save the image to. Saves the image as "%Y-%m-%d %H-%M-%S.png" 22 | 23 | `-s` Take a selection screenshot. 24 | 25 | `-u ` Upload a file. 26 | 27 | `-x` Do not notify dbus, update the log, or modify the clipboard. 28 | 29 | `-w` Take a screenshot of the current window. 30 | 31 | `-S` Select a shortener to use. Can be waaai or 0x0. 32 | 33 | `-l` Upload the file at the provided URL. 34 | 35 | ## Requirements 36 | 37 | - curl 38 | - libnotify (for notifications) 39 | - maim (for screenshot) 40 | - slop (for selection capture) 41 | - xclip (for clip-board support) 42 | - xprop (for current window capture) 43 | 44 | ## Todo 45 | 46 | POSIX sh compliance. 47 | 48 | ## Credit 49 | 50 | Huge thanks to all [GitHub contributors](https://github.com/jschx/uguush/graphs/contributors). 51 | 52 | Big thanks to [neku](https://github.com/nokonoko) for creating pomf and uguu! 53 | 54 | Inspired by [onodera-punpun](https://github.com/onodera-punpun)'s pomf.sh. 55 | 56 | Original upload functionality by [KittyKatt](https://github.com/KittyKatt). 57 | -------------------------------------------------------------------------------- /sxhkdrc: -------------------------------------------------------------------------------- 1 | # uguu window 2 | ctrl + shift + 2 3 | uguush -w 4 | 5 | # uguu fullscreen 6 | ctrl + shift + 3 7 | uguush -f 8 | 9 | # uguu selection 10 | ctrl + shift + @4 11 | uguush -s 12 | -------------------------------------------------------------------------------- /uguush: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # uguush - command-line uploader for uguu.se and others 4 | # 5 | 6 | ## CONFIGURATION 7 | 8 | # colors 9 | c0="$(tput sgr0)" 10 | c1="$(tput setaf 1)" 11 | c2="$(tput setaf 2)" 12 | 13 | # filename to use for screenshots 14 | localTemp="$(mktemp)" 15 | 16 | # screenshot functions 17 | capFullscreen() { 18 | localFile="${localTemp}.png" 19 | mv "${localTemp}" "${localFile}" 20 | maim -u "${localFile}" 21 | } 22 | 23 | capSelection() { 24 | localFile="${localTemp}.png" 25 | mv "${localTemp}" "${localFile}" 26 | maim -s -u "${localFile}" 27 | } 28 | 29 | capWindow() { 30 | localFile="${localTemp}.png" 31 | mv "${localTemp}" "${localFile}" 32 | maim -i $(xprop -root _NET_ACTIVE_WINDOW | grep -o '0x.*') -u 33 | } 34 | 35 | # delay 36 | delaySeconds='0' 37 | 38 | # hosts and shorteners 39 | host='uguu' 40 | shortener= 41 | hosts='uguu teknik 0x0 ptpb mixtape lewd fiery doko' 42 | shorteners='waaai 0x0' 43 | 44 | ## FUNCTIONS 45 | 46 | depends() { 47 | if [ ! type curl &> /dev/null ]; then 48 | echo >&2 "Checking for curl... [${c1}FAILED${c0}]" 49 | echo 'curl not found.' 50 | exit 1 51 | fi 52 | } 53 | 54 | usage() { 55 | cat << EOF 56 | 57 | uguush - upload to various file hosts 58 | 59 | Usage: 60 | $(basename "${0}") [options] 61 | 62 | Options: 63 | -d Delay the screenshot by the specified number of seconds. 64 | -f Take a fullscreen screenshot. 65 | -h Show this help message. 66 | -o Select a host to use. Can be uguu, teknik, 0x0, ptpb, mixtape, lewd, fiery or doko. 67 | -p Custom path to save the image to. Saves the image as "%Y-%m-%d %H-%M-%S.png". 68 | -s Take a selection screenshot. 69 | -u Upload a file. 70 | -x Do not notify dbus, update the log, or modify the clipboard. 71 | -w Take a screenshot of the current window. 72 | -S Select a shortener to use. Can be waaai or 0x0. 73 | -l Upload the file at the provided URL. 74 | 75 | EOF 76 | } 77 | 78 | delay() { 79 | for (( i=delaySeconds; i > 0; --i )); do 80 | echo "${i}..." 81 | sleep 1 82 | done 83 | } 84 | 85 | screenshot() { 86 | if [ "${doFullscreen}" ]; then 87 | capFullscreen 88 | elif [ "${doSelection}" ]; then 89 | capSelection &> /dev/null 90 | if ! [ -s "${localFile}" ]; then 91 | $(rm "${localFile}" 2> /dev/null) 92 | exit 93 | fi 94 | elif [ "${doWindow}" ]; then 95 | capWindow 96 | elif [ "${doURL}" ]; then 97 | if [ -f "/usr/share/mime/globs" ]; then 98 | urlExtension="$(curl -sf --head "${remoteURL}" | grep 'Content-Type: ' | head -1 | grep -Po '(?<=\ )[^\;]*')" 99 | urlExtension="$(echo "${urlExtension}" | sed -e "s/\\r//")" 100 | urlExtension="$(cat /usr/share/mime/globs | grep "${urlExtension}" | sort -r | head -1 | grep -Po '(?<=\.)[^\n]*')" 101 | else 102 | urlExtension="$(basename ${remoteURL})" 103 | urlExtension=${urlExtension#*.} 104 | fi 105 | localFile="${localTemp}.${urlExtension}" 106 | $(curl -sf "${remoteURL}" > "${localFile}") 107 | fi 108 | } 109 | 110 | upload() { 111 | for (( i = 1; i <= 3; i++ )); do 112 | echo -n "Try #${i}... " 113 | 114 | case "${host}" in 115 | teknik) hostURL='https://api.teknik.io/v1/Upload' ;; 116 | 0x0) hostURL='https://0x0.st/' ;; 117 | uguu) hostURL='https://uguu.se/api.php?d=upload-tool' ;; 118 | ptpb) hostURL='https://ptpb.pw/' ;; 119 | mixtape) hostURL='https://mixtape.moe/upload.php' ;; 120 | lewd) hostURL='https://lewd.se/api.php?d=upload-tool' ;; 121 | fiery) hostURL='https://safe.fiery.me/api/upload' ;; 122 | doko) hostURL='https://doko.moe/upload.php' ;; 123 | esac 124 | 125 | case "${shortener}" in 126 | waaai) shortenerURL='https://api.waa.ai/shorten' ;; 127 | 0x0) shortenerURL='http://0x0.st/' ;; 128 | ptpb) shortenerURL='https://ptpb.pw/u' 129 | esac 130 | 131 | if [ "${host}" = 'uguu' ]; then 132 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 133 | elif [ "${host}" = '0x0' ]; then 134 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 135 | elif [ "${host}" = 'teknik' ]; then 136 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 137 | uploadResult="${uploadResult##*url\":\"}" 138 | uploadResult="${uploadResult%%\"*}" 139 | elif [ "${host}" = 'mixtape' ]; then 140 | uploadResult="$(curl -sf -F files[]="@${localFile}" "${hostURL}")" 141 | uploadResult="$(echo "${uploadResult}" | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//')" 142 | uploadResult="$(echo "${uploadResult//\\\//\/}")" 143 | elif [ "${host}" = 'ptpb' ]; then 144 | uploadResult="$(curl -sf -F c="@${localFile}" "${hostURL}")" 145 | uploadResult="${uploadResult##*url: }" 146 | uploadResult="${uploadResult%%$'\n'*}" 147 | elif [ "${host}" = 'lewd' ]; then 148 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 149 | elif [ "${host}" = 'fiery' ]; then 150 | uploadResult="$(curl -sf -F files[]="@${localFile}" "${hostURL}")" 151 | uploadResult="$(echo "${uploadResult}" | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//')" 152 | elif [ "${host}" = 'doko' ]; then 153 | uploadResult="$(curl -sf -F files[]="@${localFile}" "${hostURL}")" 154 | uploadResult="$(echo "${uploadResult}" | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//')" 155 | uploadResult="$(echo "${uploadResult//\\\//\/}")" 156 | fi 157 | 158 | if [ "${shortener}" = 'waaai' ]; then 159 | tempResult="$(curl -sf -F url="${uploadResult}" "${shortenerURL}")" 160 | shortCode="${tempResult##*short_code\":\"}" 161 | shortCode="${shortCode%%\"*}" 162 | shortenerResult="https://waa.ai/${shortCode}" 163 | shortenerExtension="${tempResult##*extension\":}" 164 | shortenerExtension="${shortenerExtension%%\}*}" 165 | if [ "${shortenerExtension}" = 'true' ]; then 166 | shortenerExtension=${shortenerExtension##\"} 167 | shortenerExtension=${shortenerExtension%%\"} 168 | shortenerResult="${shortenerResult}.${shortenerExtension}" 169 | fi 170 | elif [ "${shortener}" = '0x0' ]; then 171 | shortenerResult="$(curl -sf -F shorten="${uploadResult}" "${shortenerURL}")" 172 | elif [ "${shortener}" = 'ptpb' ]; then 173 | shortenerResult="$(curl -sf -F c=@- "${shortenerURL}" <<< "${uploadResult}")" 174 | fi 175 | 176 | if [ "${shortener}" ]; then 177 | finalResult="${shortenerResult}" 178 | else 179 | finalResult="${uploadResult}" 180 | fi 181 | 182 | if [ "${?}" = 0 ]; then 183 | 184 | # copy to clipboard, log, and notify (unless $noComms is set) 185 | if [ ! "${noComms}" ]; then 186 | echo -n "${finalResult}" | xclip -selection primary 187 | echo -n "${finalResult}" | xclip -selection clipboard 188 | echo "$(date +"%D %R") | "${file}" | "${finalResult}"" >> ~/.uguush.log 189 | notify-send 'uguu~' "${finalResult}" 190 | fi 191 | fi 192 | 193 | echo "[${c2}OK${c0}]" 194 | echo "File has been uploaded: ${finalResult}" 195 | 196 | # if we took a screenshot, remove the temporary file 197 | if [ -z "${doFile}" ]; then 198 | rm "${localFile}" 199 | fi 200 | 201 | exit 202 | 203 | done 204 | } 205 | 206 | path() { 207 | if [ "${saveToPath}" = 'true' ]; then 208 | localFilename=$(date "+%Y-%m-%d %H-%M-%S") 209 | cp ${localFile} "${pathToSave}/${localFilename}.png" 210 | fi 211 | } 212 | 213 | ## PARSE OPTIONS 214 | 215 | while getopts :d:fhl:o:p:su:wxS: opt ;do 216 | case "${opt}" in 217 | d) 218 | # set delay value 219 | delaySeconds="${OPTARG}" ;; 220 | f) 221 | # take fullscreen shot 222 | doFullscreen='true' ;; 223 | h) 224 | # print help 225 | usage 226 | exit 0 ;; 227 | l) 228 | # set url to upload 229 | doURL='true' 230 | remoteURL="${OPTARG}" ;; 231 | o) 232 | # set host 233 | [[ "${hosts}" =~ "${OPTARG}" ]] && host="${OPTARG}" || exit 1 ;; 234 | p) 235 | # set path to save file 236 | saveToPath='true' 237 | pathToSave="${OPTARG}" ;; 238 | s) 239 | # take shot of selection 240 | doSelection='true' ;; 241 | u) 242 | # change $file to the specified file with -u 243 | doFile='true' 244 | localFile="${OPTARG}" ;; 245 | w) 246 | # take shot of current window 247 | doWindow='true' ;; 248 | x) 249 | # do not notify dbus, update log, or modify clipboard 250 | noComms='true' ;; 251 | S) 252 | # set shortener 253 | [[ "${shorteners}" =~ "${OPTARG}" ]] && shortener="${OPTARG}" || exit 1 ;; 254 | *) 255 | # print help and EXIT_FAILURE 256 | usage 257 | exit 1 ;; 258 | esac 259 | done 260 | 261 | # show usage if no arguments are given 262 | if [ $# -lt 1 ]; then 263 | usage 264 | exit 1 265 | fi 266 | 267 | ## EXECUTE FUNCTIONS 268 | 269 | depends 270 | delay 271 | screenshot 272 | path 273 | upload 274 | 275 | # if the program doesn't exit at the for-loop, the upload failed 276 | echo 'File was not uploaded, did you specify a valid filename?' 277 | --------------------------------------------------------------------------------