feat(hyprland): add directional focus binds

This commit is contained in:
2026-10-11 12:12:54 -04:00
parent 0bf5ebae87
commit e088ee7846
2 changed files with 54 additions and 2 deletions

View File

@@ -9,7 +9,7 @@
config = lib.mkIf config.modules.desktop.session.hyprland.enable { config = lib.mkIf config.modules.desktop.session.hyprland.enable {
registry.keybind.${config.networking.hostName} = lib.listToAttrs ( registry.keybind.${config.networking.hostName} = lib.listToAttrs (
map (workspace: { (map (workspace: {
name = "hyprland-workspace-${toString workspace}"; name = "hyprland-workspace-${toString workspace}";
value = { value = {
keys = "SUPER + ${toString workspace}"; keys = "SUPER + ${toString workspace}";
@@ -18,7 +18,40 @@
inherit workspace; 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 # This program integration owns the session, portals, and polkit, launched
@@ -53,6 +86,9 @@
(lib.generators.mkLuaInline ( (lib.generators.mkLuaInline (
{ {
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})"; 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(${ "focus-workspace" = "hl.dsp.focus(${
lib.generators.toLua { } { inherit (keybind.action) workspace; } lib.generators.toLua { } { inherit (keybind.action) workspace; }
})"; })";

View File

@@ -11,6 +11,7 @@
lib.all ( lib.all (
entry: entry:
(entry.value.action.kind == "exec" && entry.value.action.command != null) (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) || (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null)
) entries; ) entries;
message = "Desktop keybind actions must set the fields their kind requires."; message = "Desktop keybind actions must set the fields their kind requires.";
@@ -33,6 +34,7 @@
description = "Selects the keybind action kind."; description = "Selects the keybind action kind.";
type = lib.types.enum [ type = lib.types.enum [
"exec" "exec"
"focus-direction"
"focus-workspace" "focus-workspace"
]; ];
}; };
@@ -44,6 +46,20 @@
example = "ghostty"; 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 { workspace = lib.mkOption {
description = "Workspace focused by a focus-workspace keybind."; description = "Workspace focused by a focus-workspace keybind.";
type = lib.types.nullOr lib.types.int; type = lib.types.nullOr lib.types.int;