Files
mw-pfeddersheim-workstation/scripts/realign-workspaces.sh
T

61 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# Realign Hyprland workspaces to their configured monitors.
# Run this after changing monitor layout or workspace rules in hyprland.conf.
# Workspace pinning rules are NOT retroactive on reload.
#
# Current layout (3 monitors):
# workspace 1-3 -> DP-1 (left, TERRA 2560x1440@144)
# workspace 4-6 -> DVI-D-1 (center, BenQ 1920x1080@60, portrait)
# workspace 7-9 -> HDMI-A-1 (right, TERRA 2560x1440@144)
set -euo pipefail
# Check we're running inside Hyprland
if ! command -v hyprctl &>/dev/null; then
echo "ERROR: hyprctl not found. Is Hyprland installed?" >&2
exit 1
fi
if [ -z "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]; then
echo "ERROR: Not running inside a Hyprland session." >&2
exit 1
fi
echo "Realigning Hyprland workspaces to monitors..."
# Move workspaces 1-3 to left monitor (DP-1)
for ws in 1 2 3; do
echo " Moving workspace $ws -> DP-1"
hyprctl dispatch moveworkspacetomonitor "$ws" DP-1
done
# Move workspaces 4-6 to center monitor (DVI-D-1)
for ws in 4 5 6; do
echo " Moving workspace $ws -> DVI-D-1"
hyprctl dispatch moveworkspacetomonitor "$ws" DVI-D-1
done
# Move workspaces 7-9 to right monitor (HDMI-A-1)
for ws in 7 8 9; do
echo " Moving workspace $ws -> HDMI-A-1"
hyprctl dispatch moveworkspacetomonitor "$ws" HDMI-A-1
done
sleep 1
# Verify
echo ""
echo "Current workspace assignments:"
hyprctl workspaces -j 2>/dev/null | jq -r \
'.[] | " ws\(.name) -> \(.monitor) (\(.windows) window(s))"' 2>/dev/null \
|| echo " (jq parse failed, run 'hyprctl workspaces' manually)"
echo ""
echo "Configured pinning rules:"
hyprctl workspacerules -j 2>/dev/null | jq -r \
'.[] | " ws\(.workspaceString) -> \(.monitor)"' 2>/dev/null \
|| echo " (jq parse failed, run 'hyprctl workspacerules' manually)"
echo ""
echo "Done. Workspaces realigned."