feat(hyprland): add directional focus binds #150
@@ -8,18 +8,56 @@
|
|||||||
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.listToAttrs (
|
registry.keybind.${config.networking.hostName} = lib.mkMerge [
|
||||||
map (workspace: {
|
# Generate numeric workspace keybinds.
|
||||||
name = "hyprland-workspace-${toString workspace}";
|
(lib.listToAttrs (
|
||||||
value = {
|
map (workspace: {
|
||||||
keys = "SUPER + ${toString workspace}";
|
name = "hyprland-workspace-${toString workspace}";
|
||||||
action = {
|
value = {
|
||||||
kind = "focus-workspace";
|
keys = "SUPER + ${toString workspace}";
|
||||||
inherit workspace;
|
action = {
|
||||||
|
kind = "focus";
|
||||||
|
inherit workspace;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
}) (lib.range 1 9)
|
||||||
}) (lib.range 1 9)
|
))
|
||||||
);
|
# Generate directional keybinds.
|
||||||
|
(lib.listToAttrs (
|
||||||
|
map
|
||||||
|
(
|
||||||
|
{ direction, key }:
|
||||||
|
{
|
||||||
|
name = "hyprland-focus-${direction}";
|
||||||
|
value = {
|
||||||
|
keys = "SUPER + ${key}";
|
||||||
|
action = {
|
||||||
|
kind = "focus";
|
||||||
|
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
|
# This program integration owns the session, portals, and polkit, launched
|
||||||
# through the universal Wayland session manager.
|
# through the universal Wayland session manager.
|
||||||
@@ -53,8 +91,8 @@
|
|||||||
(lib.generators.mkLuaInline (
|
(lib.generators.mkLuaInline (
|
||||||
{
|
{
|
||||||
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
|
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
|
||||||
"focus-workspace" = "hl.dsp.focus(${
|
focus = "hl.dsp.focus(${
|
||||||
lib.generators.toLua { } { inherit (keybind.action) workspace; }
|
lib.generators.toLua { } { inherit (keybind.action) direction workspace; }
|
||||||
})";
|
})";
|
||||||
}
|
}
|
||||||
.${keybind.action.kind}
|
.${keybind.action.kind}
|
||||||
|
|||||||
@@ -11,7 +11,10 @@
|
|||||||
lib.all (
|
lib.all (
|
||||||
entry:
|
entry:
|
||||||
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
||||||
|| (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null)
|
|| (
|
||||||
|
entry.value.action.kind == "focus"
|
||||||
|
&& lib.xor (entry.value.action.direction != null) (entry.value.action.workspace != null)
|
||||||
|
)
|
||||||
) entries;
|
) entries;
|
||||||
message = "Desktop keybind actions must set the fields their kind requires.";
|
message = "Desktop keybind actions must set the fields their kind requires.";
|
||||||
}
|
}
|
||||||
@@ -33,7 +36,7 @@
|
|||||||
description = "Selects the keybind action kind.";
|
description = "Selects the keybind action kind.";
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
"exec"
|
"exec"
|
||||||
"focus-workspace"
|
"focus"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -44,8 +47,22 @@
|
|||||||
example = "ghostty";
|
example = "ghostty";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
direction = lib.mkOption {
|
||||||
|
description = "Direction focused by a focus keybind.";
|
||||||
|
type = lib.types.nullOr (
|
||||||
|
lib.types.enum [
|
||||||
|
"down"
|
||||||
|
"left"
|
||||||
|
"right"
|
||||||
|
"up"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
default = null;
|
||||||
|
example = "left";
|
||||||
|
};
|
||||||
|
|
||||||
workspace = lib.mkOption {
|
workspace = lib.mkOption {
|
||||||
description = "Workspace focused by a focus-workspace keybind.";
|
description = "Workspace focused by a focus keybind.";
|
||||||
type = lib.types.nullOr lib.types.int;
|
type = lib.types.nullOr lib.types.int;
|
||||||
default = null;
|
default = null;
|
||||||
example = 1;
|
example = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user