From 5bcf5c8100962ea1b784483830320cb75ed92d76 Mon Sep 17 00:00:00 2001 From: oddlama Date: Mon, 16 Oct 2023 17:04:53 +0200 Subject: [PATCH] fix: abort screenshot tool if flameshot was cancelled --- pkgs/scripts/screenshot-area.nix | 5 ++++- pkgs/scripts/screenshot-screen.nix | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/scripts/screenshot-area.nix b/pkgs/scripts/screenshot-area.nix index 484f70b..4600c8e 100644 --- a/pkgs/scripts/screenshot-area.nix +++ b/pkgs/scripts/screenshot-area.nix @@ -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" \ diff --git a/pkgs/scripts/screenshot-screen.nix b/pkgs/scripts/screenshot-screen.nix index 82eaf47..bf1cec2 100644 --- a/pkgs/scripts/screenshot-screen.nix +++ b/pkgs/scripts/screenshot-screen.nix @@ -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" \