feat(hyprland): add workspace focus keybinds
This commit was merged in pull request #148.
This commit is contained in:
@@ -8,6 +8,18 @@
|
||||
options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor";
|
||||
|
||||
config = lib.mkIf config.modules.desktop.session.hyprland.enable {
|
||||
registry.keybind.${config.networking.hostName} = lib.listToAttrs (
|
||||
map (workspace: {
|
||||
name = "hyprland-workspace-${toString workspace}";
|
||||
value = {
|
||||
keys = "SUPER + ${toString workspace}";
|
||||
action = {
|
||||
kind = "focus-workspace";
|
||||
inherit workspace;
|
||||
};
|
||||
};
|
||||
}) (lib.range 1 9)
|
||||
);
|
||||
|
||||
# This program integration owns the session, portals, and polkit, launched
|
||||
# through the universal Wayland session manager.
|
||||
@@ -38,7 +50,15 @@
|
||||
bind = lib.mapAttrsToList (_name: keybind: {
|
||||
_args = [
|
||||
keybind.keys
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})")
|
||||
(lib.generators.mkLuaInline (
|
||||
{
|
||||
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
|
||||
"focus-workspace" = "hl.dsp.focus(${
|
||||
lib.generators.toLua { } { inherit (keybind.action) workspace; }
|
||||
})";
|
||||
}
|
||||
.${keybind.action.kind}
|
||||
))
|
||||
];
|
||||
}) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind);
|
||||
};
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
assertion = util.registry.predicates.uniquePerHost (entry: entry.value.keys);
|
||||
message = "Desktop keybinds must use unique key chords per host.";
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
entries:
|
||||
lib.all (
|
||||
entry:
|
||||
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
||||
|| (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null)
|
||||
) entries;
|
||||
message = "Desktop keybind actions must set the fields their kind requires.";
|
||||
}
|
||||
];
|
||||
|
||||
type = lib.types.submodule {
|
||||
@@ -21,14 +31,25 @@
|
||||
options = {
|
||||
kind = lib.mkOption {
|
||||
description = "Selects the keybind action kind.";
|
||||
type = lib.types.enum [ "exec" ];
|
||||
type = lib.types.enum [
|
||||
"exec"
|
||||
"focus-workspace"
|
||||
];
|
||||
};
|
||||
|
||||
command = lib.mkOption {
|
||||
description = "Command executed by this keybind.";
|
||||
type = lib.types.str;
|
||||
description = "Command executed by an exec keybind.";
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
example = "ghostty";
|
||||
};
|
||||
|
||||
workspace = lib.mkOption {
|
||||
description = "Workspace focused by a focus-workspace keybind.";
|
||||
type = lib.types.nullOr lib.types.int;
|
||||
default = null;
|
||||
example = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user