refactor(hyprland): split keybind definitions

This commit is contained in:
2026-10-11 12:28:04 -04:00
parent 14a6ea8ea6
commit 337ede3ec5

View File

@@ -7,94 +7,101 @@
{ {
options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor"; options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor";
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 [
hyprland-focus-left = { {
keys = "SUPER + H"; registry.keybind.${config.networking.hostName} = {
action = { hyprland-focus-left = {
kind = "focus"; keys = "SUPER + H";
direction = "left"; action = {
}; kind = "focus";
}; direction = "left";
};
};
hyprland-focus-down = { hyprland-focus-down = {
keys = "SUPER + J"; keys = "SUPER + J";
action = { action = {
kind = "focus"; kind = "focus";
direction = "down"; direction = "down";
}; };
}; };
hyprland-focus-up = { hyprland-focus-up = {
keys = "SUPER + K"; keys = "SUPER + K";
action = { action = {
kind = "focus"; kind = "focus";
direction = "up"; direction = "up";
}; };
}; };
hyprland-focus-right = { hyprland-focus-right = {
keys = "SUPER + L"; keys = "SUPER + L";
action = { action = {
kind = "focus"; kind = "focus";
direction = "right"; direction = "right";
}; };
};
}
// lib.listToAttrs (
map (workspace: {
name = "hyprland-workspace-${toString workspace}";
value = {
keys = "SUPER + ${toString workspace}";
action = {
kind = "focus";
inherit workspace;
}; };
}; };
}) (lib.range 1 9) }
); {
registry.keybind.${config.networking.hostName} = lib.listToAttrs (
map (workspace: {
name = "hyprland-workspace-${toString workspace}";
value = {
keys = "SUPER + ${toString workspace}";
action = {
kind = "focus";
inherit workspace;
};
};
}) (lib.range 1 9)
);
}
{
# This program integration owns the session, portals, and polkit, launched
# through the universal Wayland session manager.
programs.hyprland = {
enable = true;
withUWSM = true;
};
# This program integration owns the session, portals, and polkit, launched home-manager.users.${config.user.name}.wayland.windowManager.hyprland = {
# through the universal Wayland session manager. enable = true;
programs.hyprland = {
enable = true;
withUWSM = true;
};
home-manager.users.${config.user.name}.wayland.windowManager.hyprland = { # One package drives the whole session, so there is never a version split.
enable = true; # The program integration above installs it and the portal, leaving home-
# manager to write only the config.
package = null;
portalPackage = null;
# One package drives the whole session, so there is never a version split. # uwsm owns the systemd graphical-session targets.
# The program integration above installs it and the portal, leaving home- systemd.enable = false;
# manager to write only the config.
package = null;
portalPackage = null;
# uwsm owns the systemd graphical-session targets. # Write the native Lua Hyprland config. Home Manager renders the Nix
systemd.enable = false; # settings below as hl.* calls.
configType = "lua";
# Write the native Lua Hyprland config. Home Manager renders the Nix settings = {
# settings below as hl.* calls. config.general.layout = "dwindle";
configType = "lua";
settings = { bind = lib.mapAttrsToList (_name: keybind: {
config.general.layout = "dwindle"; _args = [
keybind.keys
bind = lib.mapAttrsToList (_name: keybind: { (lib.generators.mkLuaInline (
_args = [ {
keybind.keys exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
(lib.generators.mkLuaInline ( focus = "hl.dsp.focus(${
{ lib.generators.toLua { } { inherit (keybind.action) direction workspace; }
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})"; })";
focus = "hl.dsp.focus(${ }
lib.generators.toLua { } { inherit (keybind.action) direction workspace; } .${keybind.action.kind}
})"; ))
} ];
.${keybind.action.kind} }) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind);
)) };
]; };
}) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind); }
}; ]
}; );
};
} }