37 lines
924 B
Bash
Executable File
37 lines
924 B
Bash
Executable File
#!/usr/bin/env bash
|
||
# Disable the laptop panel (eDP‑1) when any other monitor is connected,
|
||
# otherwise enable it.
|
||
|
||
set -u
|
||
|
||
# internal monitor name – change if yours differs
|
||
INT="eDP-1"
|
||
|
||
log() {
|
||
notify-send "$*"
|
||
}
|
||
|
||
output=$(hyprctl monitors 2>/dev/null) || {
|
||
echo "Error: hyprctl not found or command failed" >&2
|
||
exit 1
|
||
}
|
||
|
||
mapfile -t monitors < <(
|
||
grep -oP '(?<=^Monitor ).*?(?= \(ID )' <<<"$output"
|
||
)
|
||
|
||
len=${#monitors[@]}
|
||
|
||
if (( len == 2 )); then
|
||
hyprctl keyword monitor $INT, disable 2>/dev/null
|
||
hyprctl keyword workspace r[0-9] m[${monitors[1]}]
|
||
elif (( len == 3 )); then
|
||
hyprctl keyword monitor $INT, disable 2>/dev/null
|
||
hyprctl keyword workspace r[1-5] m[${monitors[1]}]
|
||
hyprctl keyword workspace r[6-9] m[${monitors[2]}]
|
||
hyprctl keyword workspace r[0] m[${monitors[2]}]
|
||
else
|
||
hyprctl keyword monitor $INT, preferred,auto,1.5 2>/dev/null
|
||
hyprctl reload 2>/dev/null
|
||
fi
|