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/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;