From e52bd4c9b7de3acbf4fdf97d7c0aa16d766c7090 Mon Sep 17 00:00:00 2001 From: "Reid \"reidlab" Date: Sun, 9 Jun 2024 03:10:25 -0700 Subject: [PATCH] even BETTER screenshotting --- modules/desktop/hyprland.nix | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/desktop/hyprland.nix b/modules/desktop/hyprland.nix index 3d34cf6..69088f0 100644 --- a/modules/desktop/hyprland.nix +++ b/modules/desktop/hyprland.nix @@ -76,8 +76,29 @@ in { "SUPER, Super_L, exec, ${lib.getExe pkgs.nwg-drawer}" ]; bind = let + # screenshotScript = pkgs.writeScript "screenshot" '' + # ${lib.getExe pkgs.grimblast} --freeze --notify copy area + # ''; screenshotScript = pkgs.writeScript "screenshot" '' - ${lib.getExe pkgs.grimblast} --freeze --notify copy area + temp_file=$(mktemp) + trap 'rm -f "$temp_file"' EXIT + + ${lib.getExe pkgs.grimblast} --freeze save area - > "$temp_file" || exit 1 + + cat "$temp_file" | ${lib.getExe pkgs.wl-clipboard-x11} -selection clipboard -t image/png + + action=$(${pkgs.libnotify}/bin/notify-send "Screenshot Captured" \ + --app-name="Screenshot" \ + --urgency=normal \ + --action="default=Edit Image" \ + --icon "$temp_file" \ + "Click to open in Swappy") + + case "$action" in + default) + ${lib.getExe pkgs.swappy} -f "$temp_file" + ;; + esac ''; in [ "$mod, R, exec, ${lib.getExe pkgs.rofi-wayland} -show run"