Created
December 28, 2022 21:55
-
-
Save tonkku107/91a16dce239e8f5e67531eca59bc6dbd to your computer and use it in GitHub Desktop.
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 | |
#** | |
# Screenshot wrapper script by Tonkku | |
# Since I couldn't find a screenshot app that fit my needs, | |
# I made this wrapper script over flameshot. | |
# Only downside rn is that it doesn't capture the cursor. | |
# | |
# Depends on | |
# - flameshot | |
# - curl | |
# - kdialog | |
# - xclip | |
#** | |
TMP="$(mktemp -t screenshot-XXXXXXXXXX.png)" | |
FILENAME="$(date '+%Y-%m-%d_%H-%M-%S').png" | |
UPLOADERKEY="" | |
# 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 | |
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 -eq 1 ]; then | |
xclip -selection clipboard -target image/png -i "$TMP" | |
elif [ $choice -eq 2 ]; then | |
location=$(kdialog --title "Where should this screenshot be saved?" --getsavefilename $HOME/Desktop/$FILENAME "PNG File (*.png)") | |
mv $TMP $location | |
elif [ $choice -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" | |
echo -n $REMOTE | xclip -selection clipboard | |
else | |
echo "Invalid option / cancel" | |
fi | |
trap "rm -f '$TMP'" 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment