diff --git a/configs/nixos/modules/desktop/session/hyprland/default.nix b/configs/nixos/modules/desktop/session/hyprland/default.nix index 733810a..d723a32 100644 --- a/configs/nixos/modules/desktop/session/hyprland/default.nix +++ b/configs/nixos/modules/desktop/session/hyprland/default.nix @@ -9,7 +9,7 @@ config = lib.mkIf config.modules.desktop.session.hyprland.enable { registry.keybind.${config.networking.hostName} = lib.listToAttrs ( - map (workspace: { + (map (workspace: { name = "hyprland-workspace-${toString workspace}"; value = { keys = "SUPER + ${toString workspace}"; @@ -18,7 +18,40 @@ inherit workspace; }; }; - }) (lib.range 1 9) + }) (lib.range 1 9)) + ++ + map + ( + { direction, key }: + { + name = "hyprland-focus-${direction}"; + value = { + keys = "SUPER + ${key}"; + action = { + kind = "focus-direction"; + inherit direction; + }; + }; + } + ) + [ + { + key = "H"; + direction = "left"; + } + { + key = "J"; + direction = "down"; + } + { + key = "K"; + direction = "up"; + } + { + key = "L"; + direction = "right"; + } + ] ); # This program integration owns the session, portals, and polkit, launched @@ -53,6 +86,9 @@ (lib.generators.mkLuaInline ( { exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})"; + "focus-direction" = "hl.dsp.focus(${ + lib.generators.toLua { } { inherit (keybind.action) direction; } + })"; "focus-workspace" = "hl.dsp.focus(${ lib.generators.toLua { } { inherit (keybind.action) workspace; } })"; diff --git a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix index 39026b4..ff58bda 100644 --- a/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix +++ b/configs/nixos/modules/desktop/session/hyprland/hyprlock.nix @@ -9,39 +9,6 @@ let user = config.user.name; # 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 = @@ -86,10 +53,10 @@ in # The guard drops the keypress when a locker is already up, so a second # hyprlock never stacks over the first. /* - 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 b780147..8f64fac 100644 --- a/configs/nixos/modules/desktop/session/mako.nix +++ b/configs/nixos/modules/desktop/session/mako.nix @@ -7,8 +7,6 @@ # mako as the notification daemon: toasts, a do-not-disturb mode, and history recall. let user = config.user.name; - - makoctl = "${pkgs.mako}/bin/makoctl"; in { options.modules.desktop.session.mako.enable = lib.mkEnableOption "the mako notification daemon"; @@ -36,9 +34,9 @@ in # of the session. # $mod is defined by the compositor config these binds share. /* - 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 064a25e..20460eb 100644 --- a/configs/nixos/modules/desktop/session/rofi.nix +++ b/configs/nixos/modules/desktop/session/rofi.nix @@ -10,17 +10,6 @@ let # 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"; @@ -43,10 +32,10 @@ in # The launcher and the session menu, kept next to the tool they drive. # $mod is defined by the compositor config these binds share. /* - 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 9b9f982..f1669c2 100644 --- a/configs/nixos/modules/desktop/utilities/clipboard.nix +++ b/configs/nixos/modules/desktop/utilities/clipboard.nix @@ -8,20 +8,10 @@ let user = config.user.name; - 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, 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 = @@ -41,9 +31,9 @@ in # $mod is defined by the compositor config these binds share. /* - 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 c6eb400..e05f3fd 100644 --- a/configs/nixos/modules/desktop/utilities/recording.nix +++ b/configs/nixos/modules/desktop/utilities/recording.nix @@ -8,36 +8,12 @@ let user = config.user.name; - 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 - - 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 = @@ -47,9 +23,9 @@ in home-manager.users.${user} = { # $mod is defined by the compositor config these binds share. /* - 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 016aadd..2eade74 100644 --- a/configs/nixos/modules/desktop/utilities/screenshot.nix +++ b/configs/nixos/modules/desktop/utilities/screenshot.nix @@ -9,28 +9,8 @@ let user = config.user.name; - 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 = @@ -43,20 +23,20 @@ in # windowrule v3 syntax: space-separated field/value tokens, comma # separated, with matchers under a match: prefix and effects bare. /* - wayland.windowManager.hyprland.settings.windowrule = [ - "float 1, match:class ^(com\\.gabm\\.satty)$" - ]; + wayland.windowManager.hyprland.settings.windowrule = [ + "float 1, match:class ^(com\\.gabm\\.satty)$" + ]; */ # 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"}" - ]; + wayland.windowManager.hyprland.settings.bind = [ + ", Print, exec, ${capture "area"}" + "SHIFT, Print, exec, ${capture "active"}" + "CTRL, Print, exec, ${capture "screen"}" + ]; */ }; }; diff --git a/configs/nixos/registry/keybind.nix b/configs/nixos/registry/keybind.nix index 8bc80fa..4bc3f8c 100644 --- a/configs/nixos/registry/keybind.nix +++ b/configs/nixos/registry/keybind.nix @@ -11,6 +11,7 @@ lib.all ( entry: (entry.value.action.kind == "exec" && entry.value.action.command != null) + || (entry.value.action.kind == "focus-direction" && entry.value.action.direction != null) || (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null) ) entries; message = "Desktop keybind actions must set the fields their kind requires."; @@ -33,6 +34,7 @@ description = "Selects the keybind action kind."; type = lib.types.enum [ "exec" + "focus-direction" "focus-workspace" ]; }; @@ -44,6 +46,20 @@ example = "ghostty"; }; + direction = lib.mkOption { + description = "Direction focused by a focus-direction keybind."; + type = lib.types.nullOr ( + lib.types.enum [ + "down" + "left" + "right" + "up" + ] + ); + default = null; + example = "left"; + }; + workspace = lib.mkOption { description = "Workspace focused by a focus-workspace keybind."; type = lib.types.nullOr lib.types.int;