feat(hyprland): add directional window movement binds

This commit is contained in:
2026-10-11 13:00:26 -04:00
parent a2fc568704
commit 40a3f6b1cc
2 changed files with 58 additions and 34 deletions

View File

@@ -4,6 +4,26 @@
... ...
}: }:
# The Hyprland compositor. # The Hyprland compositor.
let
directions = [
{
key = "H";
direction = "left";
}
{
key = "J";
direction = "down";
}
{
key = "K";
direction = "up";
}
{
key = "L";
direction = "right";
}
];
in
{ {
options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor"; options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor";
@@ -24,38 +44,35 @@
)) ))
# Generate directional keybinds. # Generate directional keybinds.
(lib.listToAttrs ( (lib.listToAttrs (
map map (
( { direction, key }:
{ direction, key }: {
{ name = "hyprland-focus-${direction}";
name = "hyprland-focus-${direction}"; value = {
value = { keys = "SUPER + ${key}";
keys = "SUPER + ${key}"; action = {
action = { kind = "focus";
kind = "focus"; inherit direction;
inherit direction;
};
}; };
} };
) }
[ ) directions
{ ))
key = "H"; # Generate directional window movement keybinds.
direction = "left"; (lib.listToAttrs (
} map (
{ { direction, key }:
key = "J"; {
direction = "down"; name = "hyprland-move-${direction}";
} value = {
{ keys = "SUPER + Shift + ${key}";
key = "K"; action = {
direction = "up"; kind = "move-window";
} inherit direction;
{ };
key = "L"; };
direction = "right"; }
} ) directions
]
)) ))
]; ];
@@ -94,6 +111,9 @@
focus = "hl.dsp.focus(${ focus = "hl.dsp.focus(${
lib.generators.toLua { } { inherit (keybind.action) direction workspace; } lib.generators.toLua { } { inherit (keybind.action) direction workspace; }
})"; })";
"move-window" = "hl.dsp.window.move(${
lib.generators.toLua { } { inherit (keybind.action) direction workspace; }
})";
} }
.${keybind.action.kind} .${keybind.action.kind}
)) ))

View File

@@ -12,7 +12,10 @@
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" builtins.elem entry.value.action.kind [
"focus"
"move-window"
]
&& lib.xor (entry.value.action.direction != null) (entry.value.action.workspace != null) && lib.xor (entry.value.action.direction != null) (entry.value.action.workspace != null)
) )
) entries; ) entries;
@@ -37,6 +40,7 @@
type = lib.types.enum [ type = lib.types.enum [
"exec" "exec"
"focus" "focus"
"move-window"
]; ];
}; };
@@ -48,7 +52,7 @@
}; };
direction = lib.mkOption { direction = lib.mkOption {
description = "Direction focused by a focus keybind."; description = "Direction targeted by a keybind action.";
type = lib.types.nullOr ( type = lib.types.nullOr (
lib.types.enum [ lib.types.enum [
"down" "down"
@@ -62,7 +66,7 @@
}; };
workspace = lib.mkOption { workspace = lib.mkOption {
description = "Workspace focused by a focus keybind."; description = "Workspace targeted by a keybind action.";
type = lib.types.nullOr lib.types.int; type = lib.types.nullOr lib.types.int;
default = null; default = null;
example = 1; example = 1;