From a8bd4bf4cfbd8b07a33146368257a6465ea572bd Mon Sep 17 00:00:00 2001 From: alexion Date: Sun, 11 Oct 2026 14:52:39 -0400 Subject: [PATCH] feat(hyprland): add window movement binds --- .../desktop/session/hyprland/default.nix | 66 +++++++++++++------ configs/nixos/registry/keybind.nix | 10 ++- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/configs/nixos/modules/desktop/session/hyprland/default.nix b/configs/nixos/modules/desktop/session/hyprland/default.nix index 5bcd5fb..b322f9d 100644 --- a/configs/nixos/modules/desktop/session/hyprland/default.nix +++ b/configs/nixos/modules/desktop/session/hyprland/default.nix @@ -11,32 +11,57 @@ registry.keybind.${config.networking.hostName} = lib.mkMerge [ # Generate numeric workspace keybinds. (lib.listToAttrs ( - map (workspace: { - name = "hyprland-workspace-${toString workspace}"; - value = { - keys = "SUPER + ${toString workspace}"; - action = { - kind = "focus"; - inherit workspace; + lib.concatMap (workspace: [ + { + name = "hyprland-workspace-${toString workspace}"; + value = { + keys = "SUPER + ${toString workspace}"; + action = { + kind = "focus"; + inherit workspace; + }; }; - }; - }) (lib.range 1 9) + } + { + name = "hyprland-move-to-workspace-${toString workspace}"; + value = { + keys = "SUPER + SHIFT + ${toString workspace}"; + action = { + kind = "move-window"; + inherit workspace; + }; + }; + } + ]) (lib.range 1 9) )) + # Generate directional keybinds. (lib.listToAttrs ( - map + lib.concatMap ( { direction, key }: - { - name = "hyprland-focus-${direction}"; - value = { - keys = "SUPER + ${key}"; - action = { - kind = "focus"; - inherit direction; + [ + { + name = "hyprland-focus-${direction}"; + value = { + keys = "SUPER + ${key}"; + action = { + kind = "focus"; + inherit direction; + }; }; - }; - } + } + { + name = "hyprland-move-${direction}"; + value = { + keys = "SUPER + SHIFT + ${key}"; + action = { + kind = "move-window"; + inherit direction; + }; + }; + } + ] ) [ { @@ -94,6 +119,9 @@ focus = "hl.dsp.focus(${ 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} )) diff --git a/configs/nixos/registry/keybind.nix b/configs/nixos/registry/keybind.nix index 05530b7..198d44f 100644 --- a/configs/nixos/registry/keybind.nix +++ b/configs/nixos/registry/keybind.nix @@ -12,7 +12,10 @@ entry: (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) ) ) entries; @@ -37,6 +40,7 @@ type = lib.types.enum [ "exec" "focus" + "move-window" ]; }; @@ -48,7 +52,7 @@ }; direction = lib.mkOption { - description = "Direction focused by a focus keybind."; + description = "Direction targeted by a keybind action."; type = lib.types.nullOr ( lib.types.enum [ "down" @@ -62,7 +66,7 @@ }; workspace = lib.mkOption { - description = "Workspace focused by a focus keybind."; + description = "Workspace targeted by a keybind action."; type = lib.types.nullOr lib.types.int; default = null; example = 1;