58 lines
1.9 KiB
Nix
58 lines
1.9 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
# Keyboard-driven screenshots copy to the clipboard before Satty opens for
|
|
# annotation. Satty copies annotated screenshots when it saves them.
|
|
let
|
|
screenshotKey = keys: target: {
|
|
inherit keys;
|
|
action = {
|
|
kind = "exec";
|
|
command = "${capture target}";
|
|
};
|
|
};
|
|
|
|
# Copy the original screenshot before Satty opens.
|
|
# Satty copies and saves annotated screenshots when the user presses Enter.
|
|
capture =
|
|
target:
|
|
pkgs.writeShellScript "screenshot-${target}" ''
|
|
dir="$(${lib.getExe' pkgs.xdg-user-dirs "xdg-user-dir"} PICTURES)/Screenshots"
|
|
${lib.getExe' pkgs.coreutils "mkdir"} -p "$dir"
|
|
${lib.getExe pkgs.grimblast} save ${target} - \
|
|
| ${lib.getExe' pkgs.coreutils "tee"} >(${lib.getExe' pkgs.wl-clipboard "wl-copy"}) \
|
|
| ${lib.getExe pkgs.satty} --filename - \
|
|
--output-filename "$dir/screenshot-%Y%m%d-%H%M%S.png" \
|
|
--copy-command ${lib.getExe' pkgs.wl-clipboard "wl-copy"} \
|
|
--save-after-copy \
|
|
--early-exit \
|
|
--actions-on-enter save-to-clipboard
|
|
'';
|
|
in
|
|
{
|
|
options.modules.desktop.utilities.screenshot.enable =
|
|
lib.mkEnableOption "screenshots via grimblast and satty";
|
|
|
|
config = lib.mkIf config.modules.desktop.utilities.screenshot.enable {
|
|
home-manager.users.${config.user.name} = {
|
|
# satty is a one-shot annotation surface, so float it rather than letting
|
|
# it claim a tile in the layout.
|
|
wayland.windowManager.hyprland.settings.window_rule = [
|
|
{
|
|
match.class = "^(com\\.gabm\\.satty)$";
|
|
float = true;
|
|
}
|
|
];
|
|
};
|
|
|
|
registry.keybind.${config.networking.hostName} = {
|
|
screenshot-area = screenshotKey "Print" "area";
|
|
screenshot-active = screenshotKey "SHIFT + Print" "active";
|
|
screenshot-screen = screenshotKey "CTRL + Print" "screen";
|
|
};
|
|
};
|
|
}
|