NixOS/home/modules/hyprland/hyprshot.nix

41 lines
1.3 KiB
Nix
Raw Permalink Normal View History

{
config,
lib,
pkgs,
...
}:
let
cfg = config.profile.hyprland;
saveDir = "${config.home.homeDirectory}/Pictures/screenshots";
in
{
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
hyprshot
satty
];
home.activation.sattyDirCreate =
lib.hm.dag.entryAfter [ "writeBoundary" ] # sh
''
mkdir -p "${saveDir}"
chown ${config.home.username} "${saveDir}"
'';
wayland.windowManager.hyprland.settings.bind =
let
2024-10-21 15:38:46 +07:00
filename = "$(date +%Y-%m-%d_%H%M%S).png";
sattyFilename = "${saveDir}/${filename}";
sattySaveCommand = ''satty --save-after-copy --filename - --fullscreen --output-filename ${sattyFilename}'';
in
[
2024-10-21 15:38:46 +07:00
"$mod, PRINT, exec, hyprshot -m window --filename ${filename} --output-folder ${saveDir}"
"$mod SHIFT, PRINT, exec, hyprshot -m window --raw | ${sattySaveCommand}"
2024-10-21 15:38:46 +07:00
", PRINT, exec, hyprshot -m region --filename ${filename} --output-folder ${saveDir}"
"SHIFT, PRINT, exec, hyprshot -m region --raw | ${sattySaveCommand}"
2024-10-21 15:38:46 +07:00
"ALT, PRINT, exec, hyprshot -m output --filename ${filename} --output-folder ${saveDir}"
"ALT SHIFT, PRINT, exec, hyprshot -m output --raw | ${sattySaveCommand}"
];
};
}