{ 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" ]; }; }; }; }