From 96a2d1b8cf327c7e5f07dbd92e610c56b2bb3ae9 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 1 Sep 2020 11:52:19 +0200 Subject: [PATCH] Prevent flameshot scripts from uploading empty files on screenshot abortion --- flameshot_upload.sh | 8 ++++++++ flameshot_upload_latest.sh | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/flameshot_upload.sh b/flameshot_upload.sh index c925fe2..c21afd7 100755 --- a/flameshot_upload.sh +++ b/flameshot_upload.sh @@ -8,6 +8,14 @@ file_name+=$base_name flameshot gui -r > $file_name +sum1=$(cat $file_name | md5sum) +sum2=$(echo -e "screenshot aborted" | md5sum) + +if test "$sum1" = "$sum2"; then + notify-send "Screenshot aborted" "$url" --icon=flameshot.svg + exit +fi + url=$(sh $(dirname $0)/upload_file.sh $file_name) echo $url | xclip -selection clipboard diff --git a/flameshot_upload_latest.sh b/flameshot_upload_latest.sh index 72ce40b..535612f 100755 --- a/flameshot_upload_latest.sh +++ b/flameshot_upload_latest.sh @@ -7,6 +7,15 @@ base_name=$latest_screenshot file_name+=$base_name + +sum1=$(cat $file_name | md5sum) +sum2=$(echo -e "screenshot aborted" | md5sum) + +if test "$sum1" = "$sum2"; then + notify-send "Last screenshot was aborted" "$url" --icon=flameshot.svg + exit +fi + url=$(sh $(dirname $0)/upload_file.sh $file_name) echo $url | xclip -selection clipboard