Add screenshot tool with SUPER+SHIFT+S bind
This commit is contained in:
parent
3db6ad962e
commit
87c7040239
|
|
@ -11,6 +11,7 @@
|
||||||
./fzf.nix
|
./fzf.nix
|
||||||
./hyprland
|
./hyprland
|
||||||
./kitty.nix
|
./kitty.nix
|
||||||
|
./screenshot.nix
|
||||||
./stylix.nix
|
./stylix.nix
|
||||||
./vscodium.nix
|
./vscodium.nix
|
||||||
./walker.nix
|
./walker.nix
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.modules.screenshot;
|
||||||
|
hyprlandCfg = config.modules.hyprland;
|
||||||
|
|
||||||
|
runtimeDeps = with pkgs; [
|
||||||
|
coreutils
|
||||||
|
grim
|
||||||
|
libnotify
|
||||||
|
slurp
|
||||||
|
util-linux
|
||||||
|
wl-clipboard
|
||||||
|
];
|
||||||
|
|
||||||
|
screenshot = pkgs.writeShellScriptBin "screenshot" ''
|
||||||
|
PATH=${lib.makeBinPath runtimeDeps}:''${PATH:-}
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
pictures_dir="$(xdg-user-dir PICTURES 2>/dev/null || echo "$HOME/Pictures")"
|
||||||
|
mkdir -p "$pictures_dir"
|
||||||
|
|
||||||
|
file="$pictures_dir/screenshot_$(date +%Y-%m-%d_%H-%M-%S).png"
|
||||||
|
|
||||||
|
notify() {
|
||||||
|
notify-send -t 2500 -u low "Screenshot" "$1" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pick a region (Escape or a plain click cancels)
|
||||||
|
geometry="$(slurp 2>/dev/null)" || exit 0
|
||||||
|
|
||||||
|
if ! grim -g "$geometry" "$file"; then
|
||||||
|
rm -f "$file"
|
||||||
|
notify "Capture failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
wl-copy < "$file" 2>/dev/null || true
|
||||||
|
|
||||||
|
notify "Saved to $file (also copied to clipboard)"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [ screenshot ];
|
||||||
|
|
||||||
|
wayland.windowManager.hyprland = mkIf hyprlandCfg.enable {
|
||||||
|
settings = {
|
||||||
|
bind = [ "SUPER SHIFT, S, exec, screenshot" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
./localsend.nix
|
./localsend.nix
|
||||||
./pipewire.nix
|
./pipewire.nix
|
||||||
./plasma.nix
|
./plasma.nix
|
||||||
|
./screenshot.nix
|
||||||
./shell.nix
|
./shell.nix
|
||||||
./system.nix
|
./system.nix
|
||||||
./tailscale.nix
|
./tailscale.nix
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
options.modules.screenshot = {
|
||||||
|
enable = mkEnableOption {
|
||||||
|
default = false;
|
||||||
|
description = "Enable screenshot capture tool (SUPER+SHIFT+S)";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -24,5 +24,7 @@
|
||||||
|
|
||||||
modules.dictation.enable = true;
|
modules.dictation.enable = true;
|
||||||
|
|
||||||
|
modules.screenshot.enable = true;
|
||||||
|
|
||||||
modules.tailscale.enable = true;
|
modules.tailscale.enable = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue