Last active
July 20, 2026 14:04
-
-
Save tonkku107/91a16dce239e8f5e67531eca59bc6dbd to your computer and use it in GitHub Desktop.
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 | |
| #** | |
| # Screenshot wrapper script by Tonkku | |
| # Since I couldn't find a screenshot app that fit my needs, | |
| # I made this wrapper script over flameshot. | |
| # | |
| # Depends on | |
| # - flameshot | |
| # - curl | |
| # - kdialog | |
| # On X11: | |
| # - xclip | |
| # On Wayland: | |
| # - wl-clipboard | |
| #** | |
| TMP="$(mktemp -t screenshot-XXXXXXXXXX.png)" | |
| FILENAME="$(date '+%Y-%m-%d_%H-%M-%S').png" | |
| UPLOADERKEY="" | |
| # Clean up on exit | |
| trap "rm -f '$TMP'" 0 | |
| function copyText { | |
| if [ "$XDG_SESSION_TYPE" = "wayland" ]; then | |
| wl-copy $1 | |
| else | |
| echo -n $1 | xclip -selection clipboard | |
| fi | |
| } | |
| function copyImage { | |
| if [ "$XDG_SESSION_TYPE" = "wayland" ]; then | |
| wl-copy < $1 | |
| else | |
| xclip -selection clipboard -target image/png -i "$1" | |
| fi | |
| } | |
| # Take screenshot (flameshot doesn't like if the file already exists) | |
| rm $TMP | |
| flameshot gui -p $TMP | |
| # Check if screenshot was canceled | |
| if [ ! -f "$TMP" ]; then | |
| exit 0 | |
| fi | |
| # Upload / Save | |
| choice=$(kdialog --title "Choose action" --radiolist "Choose action" 1 "Copy to clipboard" on 2 "Save as..." off 3 "Upload to example.com" off) | |
| if [ "${choice:-0}" -eq 1 ]; then | |
| copyImage $TMP | |
| notify-send --icon=dialog-information "Copied to clipboard" | |
| elif [ "${choice:-0}" -eq 2 ]; then | |
| location=$(kdialog --title "Where should this screenshot be saved?" --getsavefilename $HOME/Desktop/$FILENAME "PNG File (*.png)") | |
| mv $TMP $location | |
| notify-send --icon=dialog-information "Saved to $location" | |
| elif [ "${choice:-0}" -eq 3 ]; then | |
| notify-send --icon=dialog-information "Uploading..." | |
| REMOTE=$(curl -F "file=@$TMP;filename=$FILENAME" -H "key: $UPLOADERKEY" https://example.com/upload) | |
| notify-send --icon=dialog-information "Uploaded. $REMOTE" | |
| copyText $REMOTE | |
| else | |
| echo "Invalid option / cancel" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment