diff --git a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix index 117ed29..46ee9c7 100644 --- a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix +++ b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix @@ -1,13 +1,52 @@ { config, lib, + # pkgs, ... }: # The lock screen: a hyprlock session-lock surface the compositor owns. let user = config.user.name; - # The hyprlock this module installs, used by the lock keybind below. + /* + 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"; + + sleepIcon = builtins.fromJSON ''"\udb81\udcb2"''; + sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"''; + + 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 + } + + 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 + ''; + */ in { options.modules.desktop.session.hyprland.hyprlock.enable = diff --git a/configs/nixos/modules/desktop/session/mako.nix b/configs/nixos/modules/desktop/session/mako.nix index 6ab238a..121dd11 100644 --- a/configs/nixos/modules/desktop/session/mako.nix +++ b/configs/nixos/modules/desktop/session/mako.nix @@ -1,11 +1,19 @@ { config, lib, + # 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"; + */ in { options.modules.desktop.session.mako.enable = lib.mkEnableOption "the mako notification daemon"; diff --git a/configs/nixos/modules/desktop/session/rofi.nix b/configs/nixos/modules/desktop/session/rofi.nix index 01fdfb4..27a4478 100644 --- a/configs/nixos/modules/desktop/session/rofi.nix +++ b/configs/nixos/modules/desktop/session/rofi.nix @@ -1,14 +1,31 @@ { config, lib, + # pkgs, ... }: # rofi as the desktop launcher and dmenu-style menu frontend. let user = config.user.name; - # A session menu built on the same themed rofi, so the power actions look - # like every other menu the launcher drives. + /* + 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 + ''; + */ in { options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher"; diff --git a/configs/nixos/modules/desktop/utilities/clipboard.nix b/configs/nixos/modules/desktop/utilities/clipboard.nix index fac4cf1..6959abd 100644 --- a/configs/nixos/modules/desktop/utilities/clipboard.nix +++ b/configs/nixos/modules/desktop/utilities/clipboard.nix @@ -8,10 +8,25 @@ let user = config.user.name; - # 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. + /* + 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"; + + # 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} + ''; + */ in { options.modules.desktop.utilities.clipboard.enable = diff --git a/configs/nixos/modules/desktop/utilities/recording.nix b/configs/nixos/modules/desktop/utilities/recording.nix index 7cfc356..d4190fd 100644 --- a/configs/nixos/modules/desktop/utilities/recording.nix +++ b/configs/nixos/modules/desktop/utilities/recording.nix @@ -1,18 +1,48 @@ { config, lib, + # pkgs, ... }: # Keybound screen recording: pick a region, then toggle a video-only capture. let user = config.user.name; - # 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. + /* + 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"; + + # 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" + + ${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 = diff --git a/configs/nixos/modules/desktop/utilities/screenshot.nix b/configs/nixos/modules/desktop/utilities/screenshot.nix index 69efe15..c50214b 100644 --- a/configs/nixos/modules/desktop/utilities/screenshot.nix +++ b/configs/nixos/modules/desktop/utilities/screenshot.nix @@ -1,6 +1,7 @@ { config, lib, + # pkgs, ... }: # Keyboard-driven screenshots copy to the clipboard before Satty opens for @@ -8,8 +9,33 @@ let user = config.user.name; - # Copy the original screenshot before Satty opens. - # Satty copies and saves annotated screenshots when the user presses Enter. + /* + 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"; + + # 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 =