{ config, lib, pkgs, ... }: # Keyboard-driven screenshots that open in satty for annotation, then land in # both the clipboard and a dated file. let cfg = config.modules.desktop.screenshot; user = config.user.name; grimblast = "${pkgs.grimblast}/bin/grimblast"; satty = "${pkgs.satty}/bin/satty"; wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir"; # satty is the annotation step, and its copy action is set to save as well, # so a single keystroke through it lands the shot in both the clipboard and a # file. capture = target: pkgs.writeShellScript "screenshot-${target}" '' dir="$(${xdgUserDir} PICTURES)/Screenshots" mkdir -p "$dir" ${grimblast} save ${target} - \ | ${satty} --filename - \ --output-filename "$dir/screenshot-%Y%m%d-%H%M%S.png" \ --copy-command ${wl-copy} \ --save-after-copy \ --early-exit \ --actions-on-enter save-to-clipboard ''; in { options.modules.desktop.screenshot.enable = lib.mkEnableOption "screenshots via grimblast and satty"; config = lib.mkIf cfg.enable { home-manager.users.${user} = { # satty is a one-shot annotation surface, so float it rather than letting # it claim a tile in the layout. # windowrule v3 syntax: space-separated field/value tokens, comma # separated, with matchers under a match: prefix and effects bare. wayland.windowManager.hyprland.settings.windowrule = [ "float 1, match:class ^(com\\.gabm\\.satty)$" ]; # Print with plain/Shift/Ctrl for region/window/full. # Super+L, the spec's chosen key, is already the hjkl focus and movement # bind, so screenshots take the Print key instead. wayland.windowManager.hyprland.settings.bind = [ ", Print, exec, ${capture "area"}" "SHIFT, Print, exec, ${capture "active"}" "CTRL, Print, exec, ${capture "screen"}" ]; }; }; }