From e6f13164a891c5c486427c1e6797785c19735ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Mon, 19 Feb 2024 14:47:46 +0300 Subject: [PATCH] don't save the file if nothing was shot --- ss_rect.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ss_rect.sh b/ss_rect.sh index 5e76be4..bf380c2 100755 --- a/ss_rect.sh +++ b/ss_rect.sh @@ -5,4 +5,13 @@ # Select an area with slurp, ss with grim # and copy to clipboard. SS="/media/fyb/share/shoka/swap/screenshots" -grim -c -g "$( slurp )" - | wl-copy --type image/png && wl-paste > "$SS"/$( date +'%Y-%m-%d-%H%M%S.png' ) +TEMP_FILE="$HOME/temporary_screenshot" + +grim -c -g "$( slurp )" "$TEMP_FILE" + +if [ $? -eq 0 ]; then + wl-copy --type image/png < "$TEMP_FILE" + wl-paste > "$SS/$( date +'%Y-%m-%d-%H%M%S.png' )" + rm "$TEMP_FILE" +fi +