diff --git a/home/programs/graphical/wms/hyprland/config/keybinds.nix b/home/programs/graphical/wms/hyprland/config/keybinds.nix index cd9fc84..171791a 100644 --- a/home/programs/graphical/wms/hyprland/config/keybinds.nix +++ b/home/programs/graphical/wms/hyprland/config/keybinds.nix @@ -89,7 +89,10 @@ # # Move floating windows # - # TODO: requires script (move-window.sh) + "SUPER_ALT, left, exec, hyprland-move-window 100 l" + "SUPER_ALT, right, exec, hyprland-move-window 100 r" + "SUPER_ALT, up, exec, hyprland-move-window 100 u" + "SUPER_ALT, down, exec, hyprland-move-window 100 d" # # Override split direction for next window (manual tiling) diff --git a/home/programs/graphical/wms/hyprland/default.nix b/home/programs/graphical/wms/hyprland/default.nix index ba062f0..1cc249b 100644 --- a/home/programs/graphical/wms/hyprland/default.nix +++ b/home/programs/graphical/wms/hyprland/default.nix @@ -6,7 +6,7 @@ }: let inherit (lib) mkIf; - inherit (import ./packages {inherit pkgs;}) hyprland-swap-workspace; + inherit (import ./packages {inherit pkgs;}) hyprland-swap-workspace hyprland-move-window; cfg = osConfig.myOptions.home-manager.wms.hyprland; in { @@ -17,6 +17,7 @@ in { config = mkIf cfg.enable { home.packages = with pkgs; [ hyprland-swap-workspace + hyprland-move-window ]; wayland.windowManager.hyprland = { diff --git a/home/programs/graphical/wms/hyprland/packages/default.nix b/home/programs/graphical/wms/hyprland/packages/default.nix index 773332b..47fca74 100644 --- a/home/programs/graphical/wms/hyprland/packages/default.nix +++ b/home/programs/graphical/wms/hyprland/packages/default.nix @@ -4,6 +4,7 @@ }: let packages = { hyprland-swap-workspace = pkgs.callPackage ./hyprland-swap-workspace {}; + hyprland-move-window = pkgs.callPackage ./hyprland-move-window {}; }; in packages diff --git a/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/default.nix b/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/default.nix new file mode 100644 index 0000000..1bcd3a6 --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/default.nix @@ -0,0 +1,5 @@ +{pkgs, ...}: + pkgs.writeShellScriptBin "hyprland-move-window" '' + ${builtins.readFile ./hyprland-move-window.sh} + '' + diff --git a/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/hyprland-move-window.sh b/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/hyprland-move-window.sh new file mode 100644 index 0000000..f71fa8b --- /dev/null +++ b/home/programs/graphical/wms/hyprland/packages/hyprland-move-window/hyprland-move-window.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +RESIZE_SIZE=${1:?Missing resize size} + +RESIZE_PARAMS_X=0 +RESIZE_PARAMS_Y=0 + +DIRECTION=${2:?Missing move direction} +case $DIRECTION in +l) + RESIZE_PARAMS_X=-$RESIZE_SIZE + ;; +r) + RESIZE_PARAMS_X=$RESIZE_SIZE + ;; +u) + RESIZE_PARAMS_Y=-$RESIZE_SIZE + ;; +d) + RESIZE_PARAMS_Y=$RESIZE_SIZE + ;; +*) + echo "kbye" + return 1 + ;; +esac + +ACTIVE_WINDOW=$(hyprctl activewindow -j) +IS_FLOATING=$(echo "$ACTIVE_WINDOW" | jq .floating) + +if [ "$IS_FLOATING" = "true" ]; then + hyprctl dispatch moveactive "$RESIZE_PARAMS_X" "$RESIZE_PARAMS_Y" +else + hyprctl dispatch movewindow "$DIRECTION" +fi