refactor(hyprland): loop directional keybinds

This commit is contained in:
2026-10-11 12:54:31 -04:00
parent faf1c6e4f3
commit e18d8a9ca4

View File

@@ -9,6 +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.mkMerge [ registry.keybind.${config.networking.hostName} = lib.mkMerge [
# Generate numeric workspace focus keybinds.
(lib.listToAttrs ( (lib.listToAttrs (
map (workspace: { map (workspace: {
name = "hyprland-workspace-${toString workspace}"; name = "hyprland-workspace-${toString workspace}";
@@ -21,39 +22,41 @@
}; };
}) (lib.range 1 9) }) (lib.range 1 9)
)) ))
# Generate directional focus keybinds from Vim movement keys.
(lib.listToAttrs (
map
(
{ direction, key }:
{ {
hyprland-focus-left = { name = "hyprland-focus-${direction}";
keys = "SUPER + H"; value = {
keys = "SUPER + ${key}";
action = { action = {
kind = "focus"; kind = "focus";
direction = "left"; inherit direction;
};
};
hyprland-focus-down = {
keys = "SUPER + J";
action = {
kind = "focus";
direction = "down";
};
};
hyprland-focus-up = {
keys = "SUPER + K";
action = {
kind = "focus";
direction = "up";
};
};
hyprland-focus-right = {
keys = "SUPER + L";
action = {
kind = "focus";
direction = "right";
}; };
}; };
} }
)
[
{
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