Handle cancelled screenshot in screenshot.sh

This commit is contained in:
2024-07-14 02:16:56 +01:00
parent 064b3561a5
commit eec0a70159

View File

@ -3,5 +3,10 @@
filepath="$HOME/media/images/screenshots/$(date +%Y-%m-%d\ %H:%M:%S).png"
maim --select --hidecursor | tee "$filepath" | xclip -selection clipboard -target image/png
# send notification with a thumbnail of the screenshot taken, the name of the script, and the filepath
notify-send --icon "$filepath" "$(basename "$0")" "Screenshot saved to: $filepath"
# if maim is cancelled, tee will create an empty file, so checking if the file is empty
if [ -s "$filepath" ]; then
# send notification with a thumbnail of the screenshot taken, the name of the script, and the filepath
notify-send --icon "$filepath" "$(basename "$0")" "Screenshot saved to: $filepath"
else
rm "$filepath"
fi