add work laptop workspaces handling via custom script

This commit is contained in:
Carlos Sousa 2025-03-10 14:50:41 +01:00
parent c2be36d002
commit dabea51780
3 changed files with 42 additions and 0 deletions

View File

@ -81,3 +81,9 @@ bind = $mainMod, G, togglegroup
#############
bind = $mainMod ALT, L, exec, hyprlock
#############
### Custom Scripts
#############
bind = $mainMod ALT, R, exec, ~/.config/hypr/scripts/monitor_handler.sh

View File

@ -2,3 +2,5 @@
# All sub directories are included
#WALLPAPER_DIR="/mnt/data/Zebra/Photos/Edited"
# Device Identifier
#DEVICE_IDENTIFIER="work-laptop"

View File

@ -0,0 +1,34 @@
#!/bin/bash
# Get the config file
SCRIPT_DIR=$(dirname "$0")
source "$SCRIPT_DIR/config"
# Monitor names
EXTERNAL_LEFT="DP-9"
EXTERNAL_CENTER="DP-10"
LAPTOP="eDP-1"
if [[ "$DEVICE_IDENTIFIER" == "work-laptop" ]]; then
# Check if external monitors are connected
external_left_connected=$(hyprctl monitors | grep -c "$EXTERNAL_LEFT")
external_center_connected=$(hyprctl monitors | grep -c "$EXTERNAL_CENTER")
if [[ "$external_left_connected" -eq 1 && "$external_center_connected" -eq 1 ]]; then
# Docked: Assign workspaces to externals and laptop
for ws in {1..7}; do
hyprctl dispatch moveworkspacetomonitor "$ws $EXTERNAL_CENTER"
done
hyprctl dispatch workspace 8
hyprctl dispatch moveworkspacetomonitor "8 $EXTERNAL_LEFT"
hyprctl dispatch workspace 9
hyprctl dispatch moveworkspacetomonitor "9 $LAPTOP"
# focus on center monitor
hyprctl dispatch focusmonitor "$EXTERNAL_CENTER"
else
# Undocked: Move all workspaces to laptop
for ws in {1..9}; do
hyprctl dispatch moveworkspacetomonitor "$ws $LAPTOP"
done
fi
fi