From 7cf7ad819f1b01e68628e253f19e9d6f59e6cbc4 Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 10 Oct 2026 12:51:41 -0400 Subject: [PATCH] docs(hyprland): minimize disabled config diff --- .../desktop/session/hyprland/hyprlock.nix | 79 +++++++++---------- .../nixos/modules/desktop/session/mako.nix | 21 ++--- .../nixos/modules/desktop/session/rofi.nix | 46 +++++------ .../modules/desktop/utilities/clipboard.nix | 41 ++++------ .../modules/desktop/utilities/recording.nix | 71 ++++++++--------- .../modules/desktop/utilities/screenshot.nix | 77 +++++++++--------- 6 files changed, 153 insertions(+), 182 deletions(-) diff --git a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix index 46ee9c7..39026b4 100644 --- a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix +++ b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix @@ -1,52 +1,47 @@ { config, lib, - # pkgs, + pkgs, ... }: # The lock screen: a hyprlock session-lock surface the compositor owns. let user = config.user.name; - /* - Slice 1 disables the lock keybinds, so their supporting values stay - commented out with the bind block. + # The hyprlock this module installs, used by the lock keybind below. + hyprlock = "${config.home-manager.users.${user}.programs.hyprlock.package}/bin/hyprlock"; - # The hyprlock this module installs, used by the lock keybind below. - hyprlock = "${config.home-manager.users.${user}.programs.hyprlock.package}/bin/hyprlock"; + sleepIcon = builtins.fromJSON ''"\udb81\udcb2"''; + sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"''; - sleepIcon = builtins.fromJSON ''"\udb81\udcb2"''; - sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"''; + idleLockToggle = pkgs.writeShellScript "lockscreen-idle-inhibit-toggle" '' + unit=lockscreen-idle-inhibit.service - idleLockToggle = pkgs.writeShellScript "lockscreen-idle-inhibit-toggle" '' - unit=lockscreen-idle-inhibit.service + refresh_waybar() { + ${pkgs.procps}/bin/pkill -RTMIN+9 waybar >/dev/null 2>&1 || true + } - refresh_waybar() { - ${pkgs.procps}/bin/pkill -RTMIN+9 waybar >/dev/null 2>&1 || true - } + if ${pkgs.systemd}/bin/systemctl --user is-active --quiet "$unit"; then + ${pkgs.systemd}/bin/systemctl --user stop "$unit" + refresh_waybar + ${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepIcon}" + exit 0 + fi - if ${pkgs.systemd}/bin/systemctl --user is-active --quiet "$unit"; then - ${pkgs.systemd}/bin/systemctl --user stop "$unit" - refresh_waybar - ${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepIcon}" - exit 0 - fi - - if ${pkgs.systemd}/bin/systemd-run \ - --user \ - --collect \ - --unit=lockscreen-idle-inhibit \ - --description="Disable idle-triggered screen locking" \ - ${pkgs.systemd}/bin/systemd-inhibit \ - --what=idle \ - --who=lockscreen-hotkey \ - --why="lock screen disabled by hotkey" \ - ${pkgs.coreutils}/bin/sleep infinity >/dev/null; then - refresh_waybar - ${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepOffIcon}" - fi - ''; - */ + if ${pkgs.systemd}/bin/systemd-run \ + --user \ + --collect \ + --unit=lockscreen-idle-inhibit \ + --description="Disable idle-triggered screen locking" \ + ${pkgs.systemd}/bin/systemd-inhibit \ + --what=idle \ + --who=lockscreen-hotkey \ + --why="lock screen disabled by hotkey" \ + ${pkgs.coreutils}/bin/sleep infinity >/dev/null; then + refresh_waybar + ${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepOffIcon}" + fi + ''; in { options.modules.desktop.session.hyprland.hyprlock.enable = @@ -87,14 +82,14 @@ in }; }; + # Lock on Super+X. + # The guard drops the keypress when a locker is already up, so a second + # hyprlock never stacks over the first. /* - Slice 1 disables external Hyprland binds while the compositor config - moves to a minimal Lua baseline. - - wayland.windowManager.hyprland.settings.bind = [ - "$mod, X, exec, ${pkgs.procps}/bin/pidof hyprlock || ${hyprlock}" - "$mod CTRL, X, exec, ${idleLockToggle}" - ]; + wayland.windowManager.hyprland.settings.bind = [ + "$mod, X, exec, ${pkgs.procps}/bin/pidof hyprlock || ${hyprlock}" + "$mod CTRL, X, exec, ${idleLockToggle}" + ]; */ }; }; diff --git a/configs/nixos/modules/desktop/session/mako.nix b/configs/nixos/modules/desktop/session/mako.nix index 121dd11..b780147 100644 --- a/configs/nixos/modules/desktop/session/mako.nix +++ b/configs/nixos/modules/desktop/session/mako.nix @@ -1,19 +1,14 @@ { config, lib, - # pkgs, + pkgs, ... }: # mako as the notification daemon: toasts, a do-not-disturb mode, and history recall. let user = config.user.name; - /* - Slice 1 disables the Mako recall keybind, so its supporting value stays - commented out with the bind block. - - makoctl = "${pkgs.mako}/bin/makoctl"; - */ + makoctl = "${pkgs.mako}/bin/makoctl"; in { options.modules.desktop.session.mako.enable = lib.mkEnableOption "the mako notification daemon"; @@ -37,13 +32,13 @@ in }; }; + # Recall the last notification from history, keyboard-only like the rest + # of the session. + # $mod is defined by the compositor config these binds share. /* - Slice 1 disables external Hyprland binds while the compositor config - moves to a minimal Lua baseline. - - wayland.windowManager.hyprland.settings.bind = [ - "$mod, N, exec, ${makoctl} restore" - ]; + wayland.windowManager.hyprland.settings.bind = [ + "$mod, N, exec, ${makoctl} restore" + ]; */ }; }; diff --git a/configs/nixos/modules/desktop/session/rofi.nix b/configs/nixos/modules/desktop/session/rofi.nix index 27a4478..064a25e 100644 --- a/configs/nixos/modules/desktop/session/rofi.nix +++ b/configs/nixos/modules/desktop/session/rofi.nix @@ -1,31 +1,26 @@ { config, lib, - # pkgs, + pkgs, ... }: # rofi as the desktop launcher and dmenu-style menu frontend. let user = config.user.name; - /* - Slice 1 disables the Rofi keybinds, so their supporting script stays - commented out with the bind block. - - # A session menu built on the same themed rofi, so the power actions look - # like every other menu the launcher drives. - powerMenu = pkgs.writeShellScript "rofi-power-menu" '' - chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \ - | ${pkgs.rofi}/bin/rofi -dmenu -i -p Power) - case "$chosen" in - Lock) ${pkgs.systemd}/bin/loginctl lock-session ;; - Suspend) ${pkgs.systemd}/bin/systemctl suspend ;; - 'Log out') ${pkgs.systemd}/bin/loginctl terminate-session "$XDG_SESSION_ID" ;; - Reboot) ${pkgs.systemd}/bin/systemctl reboot ;; - 'Shut down') ${pkgs.systemd}/bin/systemctl poweroff ;; - esac - ''; - */ + # A session menu built on the same themed rofi, so the power actions look + # like every other menu the launcher drives. + powerMenu = pkgs.writeShellScript "rofi-power-menu" '' + chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \ + | ${pkgs.rofi}/bin/rofi -dmenu -i -p Power) + case "$chosen" in + Lock) ${pkgs.systemd}/bin/loginctl lock-session ;; + Suspend) ${pkgs.systemd}/bin/systemctl suspend ;; + 'Log out') ${pkgs.systemd}/bin/loginctl terminate-session "$XDG_SESSION_ID" ;; + Reboot) ${pkgs.systemd}/bin/systemctl reboot ;; + 'Shut down') ${pkgs.systemd}/bin/systemctl poweroff ;; + esac + ''; in { options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher"; @@ -45,14 +40,13 @@ in }; }; + # The launcher and the session menu, kept next to the tool they drive. + # $mod is defined by the compositor config these binds share. /* - Slice 1 disables external Hyprland binds while the compositor config - moves to a minimal Lua baseline. - - wayland.windowManager.hyprland.settings.bind = [ - "$mod, R, exec, ${pkgs.rofi}/bin/rofi -show drun" - "$mod SHIFT, X, exec, ${powerMenu}" - ]; + wayland.windowManager.hyprland.settings.bind = [ + "$mod, R, exec, ${pkgs.rofi}/bin/rofi -show drun" + "$mod SHIFT, X, exec, ${powerMenu}" + ]; */ }; }; diff --git a/configs/nixos/modules/desktop/utilities/clipboard.nix b/configs/nixos/modules/desktop/utilities/clipboard.nix index 6959abd..9b9f982 100644 --- a/configs/nixos/modules/desktop/utilities/clipboard.nix +++ b/configs/nixos/modules/desktop/utilities/clipboard.nix @@ -8,25 +8,20 @@ let user = config.user.name; - /* - Slice 1 disables the clipboard picker keybind, so its supporting values - stay commented out with the bind block. + cliphist = "${pkgs.cliphist}/bin/cliphist"; + rofi = "${pkgs.rofi}/bin/rofi"; + wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; - cliphist = "${pkgs.cliphist}/bin/cliphist"; - rofi = "${pkgs.rofi}/bin/rofi"; - wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; - - # The picker reuses the themed rofi, so history looks like every other menu - # the launcher drives. - # decode is needed because list emits id-prefixed lines rather than the - # copied bytes must be resolved back before it can be re-copied. - picker = pkgs.writeShellScript "clipboard-picker" '' - ${cliphist} list \ - | ${rofi} -dmenu -i -p Clipboard \ - | ${cliphist} decode \ - | ${wl-copy} - ''; - */ + # The picker reuses the themed rofi, so history looks like every other menu + # the launcher drives. + # decode is needed because list emits id-prefixed lines rather than the copied + # bytes, so the chosen id has to be resolved back before it can be re-copied. + picker = pkgs.writeShellScript "clipboard-picker" '' + ${cliphist} list \ + | ${rofi} -dmenu -i -p Clipboard \ + | ${cliphist} decode \ + | ${wl-copy} + ''; in { options.modules.desktop.utilities.clipboard.enable = @@ -44,13 +39,11 @@ in # session so uwsm starts and stops them with it. services.cliphist.enable = true; + # $mod is defined by the compositor config these binds share. /* - Slice 1 disables external Hyprland binds while the compositor config - moves to a minimal Lua baseline. - - wayland.windowManager.hyprland.settings.bind = [ - "$mod SHIFT, V, exec, ${picker}" - ]; + wayland.windowManager.hyprland.settings.bind = [ + "$mod SHIFT, V, exec, ${picker}" + ]; */ }; }; diff --git a/configs/nixos/modules/desktop/utilities/recording.nix b/configs/nixos/modules/desktop/utilities/recording.nix index d4190fd..c6eb400 100644 --- a/configs/nixos/modules/desktop/utilities/recording.nix +++ b/configs/nixos/modules/desktop/utilities/recording.nix @@ -1,48 +1,43 @@ { config, lib, - # pkgs, + pkgs, ... }: # Keybound screen recording: pick a region, then toggle a video-only capture. let user = config.user.name; - /* - Slice 1 disables the recording keybind, so its supporting values stay - commented out with the bind block. + slurp = "${pkgs.slurp}/bin/slurp"; + wf-recorder = "${pkgs.wf-recorder}/bin/wf-recorder"; + notify-send = "${pkgs.libnotify}/bin/notify-send"; + pgrep = "${pkgs.procps}/bin/pgrep"; + pkill = "${pkgs.procps}/bin/pkill"; + date = "${pkgs.coreutils}/bin/date"; + mkdir = "${pkgs.coreutils}/bin/mkdir"; + xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir"; - slurp = "${pkgs.slurp}/bin/slurp"; - wf-recorder = "${pkgs.wf-recorder}/bin/wf-recorder"; - notify-send = "${pkgs.libnotify}/bin/notify-send"; - pgrep = "${pkgs.procps}/bin/pgrep"; - pkill = "${pkgs.procps}/bin/pkill"; - date = "${pkgs.coreutils}/bin/date"; - mkdir = "${pkgs.coreutils}/bin/mkdir"; - xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir"; + # A single key both starts and stops. + # A running wf-recorder is stopped with SIGINT so it finalises the file. + # Otherwise slurp picks a region and wf-recorder runs in the foreground until + # that stop arrives, so this instance lives for the whole recording and then + # reports it saved. + # No -a means no audio is captured. + toggle = pkgs.writeShellScript "screen-record-toggle" '' + if ${pgrep} -x wf-recorder >/dev/null; then + ${pkill} -INT -x wf-recorder + exit 0 + fi - # A single key both starts and stops. - # A running wf-recorder is stopped with SIGINT so it finalises the file. - # Otherwise slurp picks a region and wf-recorder runs in the foreground - # until that stop arrives. - # This instance lives for the whole recording and then reports it saved. - # No -a means no audio is captured. - toggle = pkgs.writeShellScript "screen-record-toggle" '' - if ${pgrep} -x wf-recorder >/dev/null; then - ${pkill} -INT -x wf-recorder - exit 0 - fi + region=$(${slurp}) || exit 0 + dir="$(${xdgUserDir} VIDEOS)/Recordings" + ${mkdir} -p "$dir" + file="$dir/recording-$(${date} +%Y%m%d-%H%M%S).mp4" - region=$(${slurp}) || exit 0 - dir="$(${xdgUserDir} VIDEOS)/Recordings" - ${mkdir} -p "$dir" - file="$dir/recording-$(${date} +%Y%m%d-%H%M%S).mp4" - - ${notify-send} -a "Screen recording" "Recording started" "Region capture, no audio." - ${wf-recorder} -g "$region" -f "$file" - ${notify-send} -a "Screen recording" "Recording saved" "$file" - ''; - */ + ${notify-send} -a "Screen recording" "Recording started" "Region capture, no audio." + ${wf-recorder} -g "$region" -f "$file" + ${notify-send} -a "Screen recording" "Recording saved" "$file" + ''; in { options.modules.desktop.utilities.recording.enable = @@ -50,13 +45,11 @@ in config = lib.mkIf config.modules.desktop.utilities.recording.enable { home-manager.users.${user} = { + # $mod is defined by the compositor config these binds share. /* - Slice 1 disables external Hyprland binds while the compositor config - moves to a minimal Lua baseline. - - wayland.windowManager.hyprland.settings.bind = [ - "$mod SHIFT, R, exec, ${toggle}" - ]; + wayland.windowManager.hyprland.settings.bind = [ + "$mod SHIFT, R, exec, ${toggle}" + ]; */ }; }; diff --git a/configs/nixos/modules/desktop/utilities/screenshot.nix b/configs/nixos/modules/desktop/utilities/screenshot.nix index c50214b..016aadd 100644 --- a/configs/nixos/modules/desktop/utilities/screenshot.nix +++ b/configs/nixos/modules/desktop/utilities/screenshot.nix @@ -1,7 +1,7 @@ { config, lib, - # pkgs, + pkgs, ... }: # Keyboard-driven screenshots copy to the clipboard before Satty opens for @@ -9,33 +9,28 @@ let user = config.user.name; - /* - Slice 1 disables the screenshot keybinds and Satty rule, so their - supporting values stay commented out with the bind block. + grimblast = "${pkgs.grimblast}/bin/grimblast"; + satty = "${pkgs.satty}/bin/satty"; + tee = "${pkgs.coreutils}/bin/tee"; + wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; + xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir"; - grimblast = "${pkgs.grimblast}/bin/grimblast"; - satty = "${pkgs.satty}/bin/satty"; - tee = "${pkgs.coreutils}/bin/tee"; - wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy"; - xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir"; - - # 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="$(${xdgUserDir} PICTURES)/Screenshots" - mkdir -p "$dir" - ${grimblast} save ${target} - \ - | ${tee} >(${wl-copy}) \ - | ${satty} --filename - \ - --output-filename "$dir/screenshot-%Y%m%d-%H%M%S.png" \ - --copy-command ${wl-copy} \ - --save-after-copy \ - --early-exit \ - --actions-on-enter save-to-clipboard - ''; - */ + # 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="$(${xdgUserDir} PICTURES)/Screenshots" + mkdir -p "$dir" + ${grimblast} save ${target} - \ + | ${tee} >(${wl-copy}) \ + | ${satty} --filename - \ + --output-filename "$dir/screenshot-%Y%m%d-%H%M%S.png" \ + --copy-command ${wl-copy} \ + --save-after-copy \ + --early-exit \ + --actions-on-enter save-to-clipboard + ''; in { options.modules.desktop.utilities.screenshot.enable = @@ -43,19 +38,25 @@ in config = lib.mkIf config.modules.desktop.utilities.screenshot.enable { home-manager.users.${user} = { + # satty is a one-shot annotation surface, so float it rather than letting + # it claim a tile in the layout. + # windowrule v3 syntax: space-separated field/value tokens, comma + # separated, with matchers under a match: prefix and effects bare. /* - Slice 1 disables external Hyprland rules and binds while the compositor - config moves to a minimal Lua baseline. + wayland.windowManager.hyprland.settings.windowrule = [ + "float 1, match:class ^(com\\.gabm\\.satty)$" + ]; + */ - wayland.windowManager.hyprland.settings.windowrule = [ - "float 1, match:class ^(com\\.gabm\\.satty)$" - ]; - - wayland.windowManager.hyprland.settings.bind = [ - ", Print, exec, ${capture "area"}" - "SHIFT, Print, exec, ${capture "active"}" - "CTRL, Print, exec, ${capture "screen"}" - ]; + # Print with plain/Shift/Ctrl for region/window/full. + # Super+L is already the hjkl focus and movement bind, so screenshots take + # the Print key instead. + /* + wayland.windowManager.hyprland.settings.bind = [ + ", Print, exec, ${capture "area"}" + "SHIFT, Print, exec, ${capture "active"}" + "CTRL, Print, exec, ${capture "screen"}" + ]; */ }; };