├── .gitignore ├── sxhkdrc ├── .editorconfig ├── uguush-tpl ├── LICENSE ├── uguush-ksnip-tpl ├── README.md └── uguush /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode/ 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /uguush-tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # You basically bind this script to your custom keybinds instead of the main script. 4 | # e.g. 5 | # /path/to/uguush-my-tpl -s # for selection screenshot. 6 | # /path/to/uguush-my-tpl -s -d 3 # for selection screenshot that's delayed by 3 seconds. 7 | 8 | # Array of random custom fiery domains to use. 9 | # Look up what characters need to be escaped when using 'sed'. 10 | MY_CUSTOM_DOMAINS=( 11 | "subdomain.lolis.cyou" 12 | "subdomain.lolis.cyou\/but-with-paths\/since\/the-domain-supports-unlimited\/paths" 13 | ) 14 | 15 | MY_SAVE_PATH="" 16 | MY_TOKEN="" 17 | MY_ALBUM_ID="" 18 | 19 | # Choose a random domain from the array. 20 | DOMAIN=${MY_CUSTOM_DOMAINS[$RANDOM % ${#MY_CUSTOM_DOMAINS[@]} ]} 21 | 22 | # This will use KDE/Spectacle and save the screenshots to MY_SAVE_PATH. 23 | # It will also store the uploads into the fiery album with MY_ALBUM_ID. 24 | uguush -o fiery -p "$MY_SAVE_PATH" -kn -t $MY_TOKEN -a $MY_ALBUM_ID -D "$DOMAIN" "$@" 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /uguush-ksnip-tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This is intended to be used with Ksnip (https://github.com/ksnip/ksnip), 4 | # or other screenshot tools that provide the functionality of uploading with user defined scripts. 5 | # This expects it to be run with a file path as the first and only paramater. 6 | 7 | # In Ksnip, you configure user defined script through: 8 | # Options > Settings > Uploader > Script Uploader > Script (fill in full path to this script). 9 | # You may have to untick "Stop when upload script writes to StdErr", 10 | # as for some reason Ksnip was detecting this script as writing to StdErr even though it shouldn't have. 11 | # You do not need to tick "Copy script output to clipboard" if you want it to copy the URL, 12 | # as uguush by default will already do that by itself. 13 | 14 | # Array of random custom fiery domains to use. 15 | # Look up what characters need to be escaped when using 'sed'. 16 | MY_CUSTOM_DOMAINS=( 17 | "subdomain.lolis.cyou" 18 | "subdomain.lolis.cyou\/but-with-paths\/since\/the-domain-supports-unlimited\/paths" 19 | ) 20 | 21 | MY_TOKEN="" 22 | MY_ALBUM_ID="" 23 | 24 | # Choose a random domain from the array. 25 | DOMAIN=${MY_CUSTOM_DOMAINS[$RANDOM % ${#MY_CUSTOM_DOMAINS[@]} ]} 26 | 27 | # This will store the uploads into the fiery album with MY_ALBUM_ID. 28 | uguush -o fiery -t $MY_TOKEN -a $MY_ALBUM_ID -D "$DOMAIN" -u "$@" 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uguush 2 | 3 | command-line uploader for various file hosts 4 | 5 | ![Usage](https://i.fiery.me/NaSQ.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 which host to use (`uguu`, `teknik`, `0x0` or `fiery`). 20 | 21 | `-p ` Custom path to save the image to (saves as `%Y-%m-%d %H-%M-%S.png`). 22 | 23 | `-c` Copy image instead of URL to clipboard. 24 | 25 | `-n` Enable save notification (if used alongside `-p` option). 26 | 27 | `-s` Take a selection screenshot. 28 | 29 | `-u ` Upload a file. 30 | 31 | `-x` Do not notify dbus, update the log, or modify the clipboard. 32 | 33 | `-X` Skip upload. 34 | 35 | `-w` Take a screenshot of the current window. 36 | 37 | `-S ` Select a shortener to use (`waaai` or `0x0`). 38 | 39 | `-l ` Upload the file at the provided URL. 40 | 41 | `-g` Use gnome-screenshot (with `-p` saves as `Screenshot from %Y-%m-%d %H-%M-%S.png`). 42 | 43 | `-k` Use KDE/Spectacle (with `-p` saves as `Screenshot_%Y%m%d_%H%M%S.png`). 44 | 45 | `-t ` Set token (for `fiery` host). 46 | 47 | `-a ` Set numerical ID of an album (for `fiery` host). 48 | 49 | `-D ` (DEPRECATED) Set `safe.fiery.me` file domain. 50 | 51 | `-F ` Set fiery host domain. 52 | 53 | ## Screenshot tool requirements 54 | 55 | You need to have ANY (not ALL) of the following tools: 56 | 57 | - [maim](https://github.com/naelstrof/maim) & [slop](https://github.com/naelstrof/slop) (default) 58 | - scrot (fallback when maim & slop are missing) 59 | - [KDE/Spectacle](https://www.kde.org/applications/graphics/spectacle/) (if using `-k` option) 60 | - [GNOME/Screenshot](https://apps.gnome.org/app/org.gnome.Screenshot/) (if using `-g` option) 61 | 62 | ## Requirements 63 | 64 | - curl 65 | - libnotify (for notifications) 66 | - xclip (for clipboard support) 67 | - xdotool (for current window capture, not needed if using `-k` or `-g` options) 68 | 69 | ## Fiery host domain 70 | 71 | This allows using any [lolisafe (v3)](https://github.com/WeebDev/chibisafe/tree/v3.0.0) or forks of [BobbyWibowo/lolisafe](https://github.com/BobbyWibowo/lolisafe). 72 | 73 | `-o` option must be set to `fiery` since otherwise the script will default to `uguu` file host. 74 | 75 | ```bash 76 | uguush -s -k -o fiery -F my.lolisafe.domain 77 | ``` 78 | 79 | Can optionally set protocol if required (e.g. `-F "http://my-unsafe.lolisafe.domain"`) 80 | 81 | ## safe.fiery.me file domain (DEPRECATED) 82 | 83 | Read more about this at: [https://blog.fiery.me/update-about-will-always-want-me](https://blog.fiery.me/update-about-will-always-want-me). 84 | 85 | ```bash 86 | uguush -s -k -o fiery -D your-hot-neighbor.will-always-want.me 87 | ``` 88 | 89 | Keep in mind that the domains will only redirect to the actual file in `i.fiery.me` instead of masking the original URL. 90 | 91 | Though it should work pretty well with chat apps that allow link previews (e.g. Discord). 92 | 93 | ## Todo 94 | 95 | - [ ] N/A 96 | 97 | ## Credit 98 | 99 | Huge thanks to all [GitHub contributors](https://github.com/jschx/uguush/graphs/contributors). 100 | 101 | Big thanks to [neku](https://github.com/nokonoko) for creating pomf and uguu! 102 | 103 | Inspired by [onodera-punpun](https://github.com/onodera-punpun)'s pomf.sh. 104 | 105 | Original upload functionality by [KittyKatt](https://github.com/KittyKatt). 106 | -------------------------------------------------------------------------------- /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 | if [ -x "$(command -v tput)" ]; then 10 | c0="$(tput sgr0)" 11 | c1="$(tput setaf 1)" 12 | c2="$(tput setaf 2)" 13 | fi 14 | 15 | # filename to use for screenshots 16 | localTemp="$(mktemp)" 17 | 18 | # screenshot functions 19 | capFullscreen() { 20 | localFile="${localTemp}.png" 21 | mv "${localTemp}" "${localFile}" 22 | $screenshotFullscreen "${localFile}" 23 | } 24 | 25 | capSelection() { 26 | localFile="${localTemp}.png" 27 | mv "${localTemp}" "${localFile}" 28 | $screenshotSelection "${localFile}" 29 | } 30 | 31 | capWindow() { 32 | localFile="${localTemp}.png" 33 | mv "${localTemp}" "${localFile}" 34 | $screenshotWindow "${localFile}" 35 | } 36 | 37 | # delay 38 | delaySeconds='0' 39 | 40 | # hosts and shorteners 41 | host='uguu' 42 | shortener= 43 | hosts='uguu teknik 0x0 fiery' 44 | shorteners='waaai 0x0' 45 | 46 | ## FUNCTIONS 47 | 48 | depends() { 49 | if [ ! -x "$(command -v curl)" ]; then 50 | echo "Checking for curl... [${c1}FAILED${c0}]" >&2 51 | echo 'curl not found.' >&2 52 | exit 1 53 | fi 54 | } 55 | 56 | usage() { 57 | cat << EOF 58 | 59 | uguush - upload to various file hosts 60 | 61 | Usage: 62 | $(basename "${0}") [options] 63 | 64 | Options: 65 | -d Delay the screenshot by the specified number of seconds. 66 | -f Take a fullscreen screenshot. 67 | -h Show this help message. 68 | -o Select which host to use (uguu, teknik, 0x0 or fiery). 69 | -p Custom path to save the image to (saves as "%Y-%m-%d %H-%M-%S.png"). 70 | -c Copy image instead of URL to clipboard. 71 | -n Enable save notification (if used alongside -p option). 72 | -s Take a selection screenshot. 73 | -u Upload a file. 74 | -x Do not notify dbus, update the log, or modify the clipboard. 75 | -X Skip upload. 76 | -w Take a screenshot of the current window. 77 | -S Select a shortener to use (waaai or 0x0). 78 | -l Upload the file at the provided URL. 79 | -g Use gnome-screenshot (with -p saves as "Screenshot from %Y-%m-%d %H-%M-%S.png"). 80 | -k Use KDE/Spectacle (with -p saves as "Screenshot_%Y%m%d_%H%M%S.png"). 81 | -t Set token (for fiery host). 82 | -a Set numerical ID of an album (for fiery host). 83 | -D (DEPRECATED) Set safe.fiery.me file domain. 84 | -F Set fiery host domain. 85 | 86 | EOF 87 | } 88 | 89 | # id for notification 90 | if [ "$(command -v notify-send)" ]; then 91 | notifyId="uguush-$(date +%s)" 92 | fi 93 | 94 | notify() { 95 | if [ "${notifyId}" ]; then 96 | notify-send \ 97 | -a "uguush" \ 98 | -h "string:x-canonical-private-synchronous:${notifyId}" \ 99 | -h "string:private-synchronous:${notifyId}" \ 100 | -i "${2}" \ 101 | "uguu~" "${1}" 102 | fi 103 | } 104 | 105 | delay() { 106 | i="$delaySeconds" 107 | while [ "$i" -gt 0 ]; do 108 | echo "${i}..." 109 | sleep 1 110 | i="$((i-1))" 111 | done 112 | } 113 | 114 | screenshot() { 115 | if [ "${useGnomeScreenshot}" ] && [ -x "$(command -v gnome-screenshot)" ]; then 116 | screenshotFullscreen="gnome-screenshot -f" 117 | screenshotSelection="gnome-screenshot -af" 118 | screenshotWindow="gnome-screenshot -we shadow -f" 119 | elif [ "${useSpectacle}" ] && [ -x "$(command -v spectacle)" ]; then 120 | screenshotFullscreen="spectacle -bno" 121 | screenshotSelection="spectacle -rbno" 122 | screenshotWindow="spectacle -abno" 123 | elif [ -x "$(command -v maim)" ]; then 124 | screenshotFullscreen="maim -u" 125 | screenshotSelection="maim -us" 126 | screenshotWindow="maim -ui $(xdotool getactivewindow)" 127 | elif [ -x "$(command -v scrot)" ]; then 128 | screenshotFullscreen="scrot" 129 | screenshotSelection="scrot -s" 130 | screenshotWindow="scrot -u" 131 | elif [ "${doFullscreen}" ] || [ "${doSelection}" ] || [ "${doWindow}" ]; then 132 | echo "Checking for a screenshot utility... [${c1}FAILED${c0}]" >&2 133 | echo "Could not find a screenshot utility, please install 'maim' or 'scrot'" >&2 134 | if [ -f "${localTemp}" ]; then rm "${localTemp}"; fi 135 | exit 1 136 | fi 137 | 138 | if [ "${doFullscreen}" ]; then 139 | capFullscreen 140 | elif [ "${doSelection}" ]; then 141 | capSelection > /dev/null 2>&1 142 | if [ ! "${useSpectacle}" ] && [ ! -s "${localFile}" ]; then 143 | $(rm "${localFile}" 2> /dev/null) 144 | exit 145 | fi 146 | elif [ "${doWindow}" ]; then 147 | capWindow 148 | elif [ "${doURL}" ]; then 149 | if [ -f "/usr/share/mime/globs" ]; then 150 | urlExtension="$(curl -sf --head "${remoteURL}" | grep -i 'Content-Type: ' | head -1 | grep -Po '(?<=\ )[^\;]*')" 151 | urlExtension="$(echo "${urlExtension}" | sed -e "s/\\r//")" 152 | urlExtension="$(cat /usr/share/mime/globs | grep "${urlExtension}" | sort -r | head -1 | grep -Po '(?<=\.)[^\n]*')" 153 | else 154 | urlExtension="$(basename ${remoteURL})" 155 | urlExtension=${urlExtension#*.} 156 | fi 157 | localFile="${localTemp}.${urlExtension}" 158 | mv "${localTemp}" "${localFile}" 159 | $(curl -sf "${remoteURL}" > "${localFile}") 160 | fi 161 | 162 | # patch for Spectacle not deleting zero bytes temp file in time when cancelling screenshot 163 | fileSize=$(stat --printf="%s" "${localFile}") 164 | if [ "${fileSize}" -eq 0 ]; then 165 | $(rm "${localFile}" 2> /dev/null) 166 | exit 167 | fi 168 | } 169 | 170 | upload() { 171 | i="1" 172 | while [ "$i" -le 3 ]; do 173 | printf "Try #${i}... " 174 | 175 | # only show attempt notify for #2 attempt and onwards 176 | if [ ! "${noComms}" ] && [ "$i" -ge 2 ]; then 177 | notify "Uploading attempt #${i}..." "cloud-upload" 178 | fi 179 | 180 | i="$((i+1))" 181 | 182 | case "${host}" in 183 | uguu) hostURL='https://uguu.se/api.php?d=upload-tool' ;; 184 | teknik) hostURL='https://api.teknik.io/v1/Upload' ;; 185 | 0x0) hostURL='https://0x0.st/' ;; 186 | fiery) 187 | if [ "${fieryHostDomain}" ]; then 188 | hostURL="${fieryHostDomain}/api/upload" 189 | else 190 | hostURL='https://safe.fiery.me/api/upload' 191 | fi 192 | ;; 193 | esac 194 | 195 | case "${shortener}" in 196 | waaai) shortenerURL='https://api.waa.ai/shorten' ;; 197 | 0x0) shortenerURL='http://0x0.st/' ;; 198 | esac 199 | 200 | if [ "${host}" = 'uguu' ]; then 201 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 202 | elif [ "${host}" = 'teknik' ]; then 203 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 204 | uploadResult="${uploadResult##*url\":\"}" 205 | uploadResult="${uploadResult%%\"*}" 206 | elif [ "${host}" = '0x0' ]; then 207 | uploadResult="$(curl -sf -F file="@${localFile}" "${hostURL}")" 208 | elif [ "${host}" = 'fiery' ]; then 209 | uploadResult="$(curl -H "token: ${fieryToken}" -H "albumid: ${fieryAlbumId}" -sf -F files[]="@${localFile}" "${hostURL}")" 210 | uploadResult="$(echo "${uploadResult}" | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//')" 211 | if [ ! "${fieryHostDomain}" ] && [ "${fieryMeDomain}" ]; then 212 | uploadResult="$(echo "${uploadResult}" | sed "s/https:\/\/i.fiery.me\//${fieryMeDomain}\//")" 213 | fi 214 | fi 215 | 216 | if [ "${shortener}" = 'waaai' ]; then 217 | tempResult="$(curl -sf -F url="${uploadResult}" "${shortenerURL}")" 218 | shortCode="${tempResult##*short_code\":\"}" 219 | shortCode="${shortCode%%\"*}" 220 | shortenerResult="https://waa.ai/${shortCode}" 221 | shortenerExtension="${tempResult##*extension\":\"}" 222 | shortenerExtension="${shortenerExtension%%\"*}" 223 | echo "${shortenerExtension}" 224 | if [ "${shortenerExtension}" ]; then 225 | shortenerExtension=${shortenerExtension##\"} 226 | shortenerExtension=${shortenerExtension%%\"} 227 | shortenerResult="${shortenerResult}.${shortenerExtension}" 228 | fi 229 | elif [ "${shortener}" = '0x0' ]; then 230 | shortenerResult="$(curl -sf -F shorten="${uploadResult}" "${shortenerURL}")" 231 | fi 232 | 233 | if [ "${shortener}" ]; then 234 | finalResult="${shortenerResult}" 235 | else 236 | finalResult="${uploadResult}" 237 | fi 238 | 239 | if [ "${finalResult}" ]; then 240 | # copy to clipboard, log, and notify (unless $noComms is set) 241 | if [ ! "${noComms}" ]; then 242 | if [ "${copyImage}" ]; then 243 | notify "Link to screenshot:\n${finalResult}" "link" 244 | else 245 | echo -n "${finalResult}" | xclip -selection primary 246 | echo -n "${finalResult}" | xclip -selection clipboard 247 | notify "Link copied to clipboard:\n${finalResult}" "url-copy" 248 | fi 249 | fi 250 | echo "$(date +"%D %R") | "${localFile}" | "${finalResult}"" >> ~/.uguush.log 251 | echo "[${c2}OK${c0}]" 252 | echo "File has been uploaded: ${finalResult}" 253 | 254 | # if we took a screenshot, remove the temporary file 255 | if [ ! "${doFile}" ]; then 256 | rm "${localFile}" 257 | fi 258 | 259 | exit 260 | else 261 | continue 262 | fi 263 | done 264 | } 265 | 266 | copyimage() { 267 | if [ ! "${noComms}" ] && [ "${copyImage}" ]; then 268 | mimeType=$(file -b --mime-type "$localFile") 269 | xclip -selection primary -t "$mimeType" < "$localFile" 270 | xclip -selection clipboard -t "$mimeType" < "$localFile" 271 | notify "Screenshot copied to clipboard" "edit-copy" 272 | fi 273 | } 274 | 275 | path() { 276 | if [ "${saveToPath}" ]; then 277 | if [ "${useGnomeScreenshot}" ]; then 278 | # this is gnome-screenshot's default naming format 279 | localFilename="$(date '+Screenshot from %Y-%m-%d %H-%M-%S')"; 280 | elif [ "${useSpectacle}" ]; then 281 | # this is Spectacle's default naming format 282 | localFilename="$(date '+Screenshot_%Y%m%d_%H%M%S')"; 283 | else 284 | localFilename="$(date '+%Y-%m-%d %H-%M-%S')"; 285 | fi 286 | 287 | cp ${localFile} "${pathToSave}/${localFilename}.png" 288 | if [ $? -eq 0 ] && [ "${notifySave}" ]; then 289 | notify "A screenshot was saved as '${localFilename}.png' to '${pathToSave}'" "document-save" 290 | fi 291 | fi 292 | } 293 | 294 | ## PARSE OPTIONS 295 | 296 | httpProtocolRegex='^https?:\/\/' 297 | 298 | while getopts :a:cd:fhigkl:no:p:st:u:wxD:F:S:X opt ;do 299 | case "${opt}" in 300 | a) 301 | # set fiery album id 302 | fieryAlbumId="${OPTARG}" ;; 303 | c) 304 | # copy image to clipboard 305 | copyImage=true ;; 306 | d) 307 | # set delay value 308 | delaySeconds="${OPTARG}" 309 | case "${delaySeconds}" in 310 | *[!0-9]*) 311 | echo "Checking if delay is a number... [${c1}FAILED${c0}]" >&2 312 | echo 'delay is not a number.' >&2 313 | exit 1 ;; 314 | esac ;; 315 | f) 316 | # take fullscreen shot 317 | doFullscreen=true ;; 318 | h) 319 | # print help 320 | usage 321 | exit 0 ;; 322 | g) 323 | # use gnome-screenshot 324 | useGnomeScreenshot=true ;; 325 | k) 326 | # use Spectacle of KDE Plasma 327 | useSpectacle=true ;; 328 | l) 329 | # set url to upload 330 | doURL=true 331 | remoteURL="${OPTARG}" ;; 332 | n) 333 | # enable save notification 334 | notifySave=true ;; 335 | o) 336 | # set host 337 | for available in ${hosts}; do 338 | if [ "${OPTARG}" = "${available}" ]; then 339 | host="${OPTARG}" 340 | hostcheck=true 341 | break 342 | fi 343 | done 344 | [ "${hostcheck}" ] || exit 1 ;; 345 | p) 346 | # set path to save file 347 | saveToPath=true 348 | pathToSave="${OPTARG}" 349 | if [ ! -d "${pathToSave}" ]; then 350 | echo "Path ${pathToSave} not found, creating it..." 351 | mkdir -p "${pathToSave}" || exit 1 352 | fi ;; 353 | s) 354 | # take shot of selection 355 | doSelection=true ;; 356 | t) 357 | # use fiery token 358 | fieryToken="${OPTARG}" ;; 359 | u) 360 | # change $file to the specified file with -u 361 | doFile=true 362 | localFile="${OPTARG}" 363 | if [ ! -f "${localFile}" ]; then 364 | echo "Checking for file... [${c1}FAILED${c0}]" >&2 365 | echo 'File not found.' >&2 366 | exit 1 367 | fi ;; 368 | w) 369 | # take shot of current window 370 | doWindow=true ;; 371 | x) 372 | # do not notify dbus, update log, or modify clipboard 373 | noComms=true ;; 374 | D) 375 | # set safe.fiery.me file domain 376 | fieryMeDomain="${OPTARG}" 377 | if [[ ! "${fieryMeDomain}" =~ $httpProtocolRegex ]]; then 378 | fieryMeDomain="https:\/\/${fieryMeDomain}" 379 | fi ;; 380 | F) 381 | # set fiery host domain 382 | fieryHostDomain="${OPTARG}" 383 | if [[ ! "${fieryHostDomain}" =~ $httpProtocolRegex ]]; then 384 | fieryHostDomain="https://${fieryHostDomain}" 385 | fi ;; 386 | S) 387 | # set shortener 388 | for available in ${shorteners}; do 389 | if [ "${OPTARG}" = "${available}" ]; then 390 | shortener="${OPTARG}" 391 | shortenercheck=true 392 | break 393 | fi 394 | done 395 | [ "${shortenercheck}" ] || exit 1 ;; 396 | X) 397 | # skip upload 398 | skipUpload=true ;; 399 | *) 400 | # print help and EXIT_FAILURE 401 | usage 402 | exit 1 ;; 403 | esac 404 | done 405 | 406 | # show usage if no action is chosen 407 | if [ ! "${doFullscreen}" ] && [ ! "${doURL}" ] && [ ! "${doSelection}" ] && [ ! "${doFile}" ] && [ ! "${doWindow}" ]; then 408 | 409 | if [ "${fieryAlbumId}" ] || [ "${fieryToken}" ] || [ "${fieryMeDomain}" ] || [ "${fieryHostDomain}" ]; then 410 | echo "Fiery-specific options must be used during screenshots. 411 | 412 | Example: $(basename "${0}") -t TOKEN_HERE -s 413 | to take a selection screenshot and upload to fiery host using the token." >&2 414 | else 415 | usage 416 | fi 417 | 418 | exit 1 419 | fi 420 | 421 | ## EXECUTE FUNCTIONS 422 | 423 | depends 424 | 425 | # if not uploading a local file 426 | if [ ! "${doFile}" ]; then 427 | delay 428 | screenshot 429 | copyimage 430 | path 431 | fi 432 | 433 | if [ "${skipUpload}" ]; then 434 | if [ ! "${noComms}" ]; then 435 | notify "Screenshot taken, but skipped upload." "document-save" 436 | fi 437 | 438 | # if we took a screenshot, remove the temporary file 439 | if [ ! "${doFile}" ]; then 440 | rm "${localFile}" 441 | fi 442 | 443 | exit 444 | else 445 | upload 446 | fi 447 | 448 | # if the program doesn't exit at the for-loop, the upload failed 449 | echo 'File was not uploaded, did you specify a valid filename?' 450 | --------------------------------------------------------------------------------