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