Last active
May 18, 2021 15:08
-
-
Save JSH32/ebe62fc86fe26f4f9a9412d9fad35847 to your computer and use it in GitHub Desktop.
Custom screenshot uploader using maim and curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dependencies: maim, curl, jq, libnotify-bin, xclip | |
TOKEN="some-token" | |
function _notify() { | |
notify-send --expire-time 2000 \ | |
--app-name 'kawaii.sh' \ | |
--icon 'flameshot' \ | |
"Screenshot" "$1" | |
} | |
FILENAME="/tmp/screenshot.$(date +"%Y%m%d_%H%M%S").png" | |
maim -s -o $FILENAME # Take screenshot | |
res=$(curl --silent --show-error \ | |
--form "uploadFile=@$FILENAME" \ | |
--header "token:$TOKEN"\ | |
https://kawaii.sh/api/files/upload 2>&1) | |
url=$(echo $res | jq -r '.url') | |
if [[ ${url:0:7} == 'http://' || ${url:0:8} == 'https://' ]] | |
then | |
echo -n "$url" | xclip -selection clipboard | |
_notify "URL was sent to your clipboard" | |
else | |
_notify "Error: $res" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment