refactor(hyprland): share focus keybind action

This commit is contained in:
2026-10-11 12:20:48 -04:00
parent e088ee7846
commit 7cd05d219b
2 changed files with 34 additions and 26 deletions

View File

@@ -14,7 +14,7 @@
value = {
keys = "SUPER + ${toString workspace}";
action = {
kind = "focus-workspace";
kind = "focus";
inherit workspace;
};
};
@@ -28,7 +28,7 @@
value = {
keys = "SUPER + ${key}";
action = {
kind = "focus-direction";
kind = "focus";
inherit direction;
};
};
@@ -80,23 +80,26 @@
settings = {
config.general.layout = "dwindle";
bind = lib.mapAttrsToList (_name: keybind: {
_args = [
keybind.keys
(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; }
})";
}
.${keybind.action.kind}
))
];
}) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind);
bind = lib.mapAttrsToList (
_name: keybind:
let
focusOptions = lib.filterAttrs (_name: value: value != null) {
inherit (keybind.action) direction workspace;
};
in
{
_args = [
keybind.keys
(lib.generators.mkLuaInline (
{
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
focus = "hl.dsp.focus(${lib.generators.toLua { } focusOptions})";
}
.${keybind.action.kind}
))
];
}
) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind);
};
};
};