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 {
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; }
})";

View File

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