Files
nixos-configs/hosts/pinwheel/modules/screenshot/default.nix
T
Alexander Heldt a74e75d9ab 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.
2026-10-27 09:59:09 +01:00

50 lines
1.6 KiB
Nix

{
inputs,
pkgs,
lib,
config,
...
}:
let
hyprlandEnabled = config.mod.hyprland.enable;
grimblast = inputs.hyprland-contrib.packages.${pkgs.stdenv.hostPlatform.system}.grimblast;
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
pkgs.satty
];
wayland.windowManager.hyprland = lib.mkIf hyprlandEnabled {
settings = {
bind = [
(bind "SUPER + Print" area)
(bind "SUPER + CTRL + Print" screen)
(bind "SUPER + SHIFT + Print" annotateArea)
(bind "SUPER + CTRL + SHIFT + Print" annotateScreen)
];
};
};
};
}