From a74e75d9abcb2786490dfe47483175842652b8df Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 27 Oct 2026 09:59:09 +0100 Subject: [PATCH] pinwheel: Add screenshot annotation with `satty` Shift-prefixed screenshot bindings pipe the capture to satty, and notifications use a short timeout so they are not captured. --- hosts/pinwheel/modules/screenshot/default.nix | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/hosts/pinwheel/modules/screenshot/default.nix b/hosts/pinwheel/modules/screenshot/default.nix index d31fd2a..fa78ac1 100644 --- a/hosts/pinwheel/modules/screenshot/default.nix +++ b/hosts/pinwheel/modules/screenshot/default.nix @@ -9,28 +9,39 @@ let hyprlandEnabled = config.mod.hyprland.enable; grimblast = inputs.hyprland-contrib.packages.${pkgs.stdenv.hostPlatform.system}.grimblast; - area = "${pkgs.libnotify}/bin/notify-send 'ps: selected area' && ${grimblast}/bin/grimblast copy area"; - screen = "${pkgs.libnotify}/bin/notify-send 'ps: selected screen' &&${grimblast}/bin/grimblast copy output"; + satty = "${pkgs.satty}/bin/satty --filename - --copy-command ${pkgs.wl-clipboard}/bin/wl-copy --initial-tool brush --actions-on-enter save-to-clipboard,exit --early-exit copy"; + + # Short timeout so the notification is gone before the capture happens. + # Output captures are instant, so they wait for it to disappear. + notify = msg: "${pkgs.libnotify}/bin/notify-send -t 500 'ps: ${msg}'"; + waitForNotify = "${pkgs.coreutils}/bin/sleep 0.6"; + + area = "${notify "selected area"} && ${grimblast}/bin/grimblast copy area"; + screen = "${notify "selected screen"} && ${waitForNotify} && ${grimblast}/bin/grimblast copy output"; + annotateArea = "${notify "annotate area"} && ${grimblast}/bin/grimblast save area - | ${satty}"; + annotateScreen = "${notify "annotate screen"} && ${waitForNotify} && ${grimblast}/bin/grimblast save output - | ${satty}"; + + bind = keys: cmd: { + _args = [ + keys + (lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${cmd}")'') + ]; + }; in { home-manager.users.alex = { - home.packages = [ grimblast ]; + home.packages = [ + grimblast + pkgs.satty + ]; wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled { settings = { bind = [ - { - _args = [ - "SUPER + Print" - (lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${area}")'') - ]; - } - { - _args = [ - "SUPER + CTRL + Print" - (lib.generators.mkLuaInline ''hl.dsp.exec_cmd("${screen}")'') - ]; - } + (bind "SUPER + Print" area) + (bind "SUPER + CTRL + Print" screen) + (bind "SUPER + SHIFT + Print" annotateArea) + (bind "SUPER + CTRL + SHIFT + Print" annotateScreen) ]; }; };