Created
April 22, 2021 19:54
-
-
Save mewejo/057e869350ba6573d370eb318d71bb1f to your computer and use it in GitHub Desktop.
Nosey screenshot uploader for Wayland (Sway)
This file contains hidden or 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 | |
# Built for Wayland | |
# Tested on Sway https://swaywm.org/ | |
# Depends on grim, slurp, wl-clipboard and jq | |
# Obtain username and token from nosey.app and use below, or hardcode them. | |
# Usage: ./take-screenshot.sh uploadUsername uploadToken | |
username=$1 | |
password=$2 | |
# Temp file | |
tempFile=$(mktemp) | |
# Take the screenshot.. | |
screenshotImage=$(grim -g "$(slurp -d)" $tempFile) | |
screenshotShell=$(curl -s -X POST -u $username:$password https://nosey.app/api/screenshots/shells) | |
# Extract the screenshot data | |
screenshotSlug=$(echo $screenshotShell | jq -r .slug) | |
clipboardUrl=$(echo $screenshotShell | jq -r .clipboard_url) | |
# Put the URL in the clipboard | |
wl-copy $clipboardUrl | |
# Upload the screenshot | |
curl -s -X POST -u $username:$password \ | |
-H "X-HTTP-Method-Override: PUT" \ | |
-F "image=@$tempFile" \ | |
https://nosey.app/api/screenshots/shells/$screenshotSlug > /dev/null | |
# Delete the temp file | |
rm $tempFile | |
# Alert! | |
notify-send "Screenshot uploaded!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment