feat(desktop): add screenshot capture (task 0028)
Add a screenshot module wiring grimblast (grim + slurp) through the satty annotation editor, enabled by the desktop aggregator. Region, active-window, and full-screen captures each open in satty and, on confirm, land in both the clipboard and a dated file under ~/Pictures/Screenshots. Bound to Print / Shift+Print / Ctrl+Print rather than the spec's Super+L family, whose keys task 0021 already holds for hjkl focus and window movement.
This commit is contained in:
@@ -16,6 +16,7 @@ in
|
||||
modules.desktop.login.enable = lib.mkDefault true;
|
||||
modules.desktop.mako.enable = lib.mkDefault true;
|
||||
modules.desktop.rofi.enable = lib.mkDefault true;
|
||||
modules.desktop.screenshot.enable = lib.mkDefault true;
|
||||
modules.desktop.terminal.enable = lib.mkDefault true;
|
||||
modules.desktop.theming.enable = lib.mkDefault true;
|
||||
modules.desktop.waybar.enable = lib.mkDefault true;
|
||||
|
||||
50
modules/desktop/screenshot.nix
Normal file
50
modules/desktop/screenshot.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
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";
|
||||
|
||||
shotDir = "$HOME/Pictures/Screenshots";
|
||||
|
||||
# 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}" ''
|
||||
mkdir -p ${shotDir}
|
||||
${grimblast} save ${target} - \
|
||||
| ${satty} --filename - \
|
||||
--output-filename "${shotDir}/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} = {
|
||||
# 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"}"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user