fix: abort screenshot tool if flameshot was cancelled

This commit is contained in:
oddlama 2023-10-16 17:04:53 +02:00
parent 143f04fb03
commit 5bcf5c8100
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
2 changed files with 7 additions and 2 deletions

View file

@ -22,7 +22,10 @@ writeShellApplication {
export QT_SCREEN_SCALE_FACTORS=""
# Use sponge to create the file on success only
${lib.getExe flameshot} gui --raw | ${moreutils}/bin/sponge "$out"
if ${lib.getExe flameshot} gui --raw 2>&1 1> >(${moreutils}/bin/sponge "$out") | grep -q "flameshot: info:.*aborted."; then
exit 1
fi
${xclip}/bin/xclip -selection clipboard -t image/png < "$out"
action=$(${libnotify}/bin/notify-send \
"📷 Screenshot captured" "📋 copied to clipboard" \

View file

@ -15,7 +15,9 @@ writeShellApplication {
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-fullscreen.png"
mkdir -p "$(dirname "$out")"
${lib.getExe flameshot} full --raw | ${moreutils}/bin/sponge "$out"
if ${lib.getExe flameshot} full --raw 2>&1 1> >(${moreutils}/bin/sponge "$out") | grep -q "flameshot: info:.*aborted."; then
exit 1
fi
${libnotify}/bin/notify-send \
"📷 Screenshot captured" "💾 Saved to $out" \
--hint="string:wired-tag:screenshot-$date" \