36 lines
1.2 KiB
Plaintext
Executable File
36 lines
1.2 KiB
Plaintext
Executable File
|
||
#!/usr/bin/env bash
|
||
# ~/.local/bin/hypr‑auto‑internal.sh
|
||
# Disable the laptop panel (eDP‑1) when any other monitor is connected,
|
||
# otherwise enable it.
|
||
|
||
set -u
|
||
|
||
INT="eDP-1" # internal monitor name – change if yours differs
|
||
|
||
log() {
|
||
notify-send "$*"
|
||
}
|
||
|
||
# -------------------------------------------------
|
||
# 1️⃣ Get current monitor list
|
||
# -------------------------------------------------
|
||
MONS=$(hyprctl monitors 2>/dev/null || true)
|
||
|
||
# -------------------------------------------------
|
||
# 2️⃣ Decide whether an external monitor is present
|
||
# -------------------------------------------------
|
||
# Any line that is *not* the internal monitor counts as external.
|
||
if echo "$MONS" | grep -qv "$INT"; then
|
||
# At least one external monitor is connected
|
||
log "External monitor detected → disabling $INT"
|
||
hyprctl keyword monitor $INT, disable 2>/dev/null
|
||
hyprctl keyword workspace r[1-5] m[DP-4]
|
||
hyprctl keyword workspace r[6-0] m[DP-5]
|
||
else
|
||
# No external monitor → make sure the internal one is on
|
||
log "No external monitor → enabling $INT"
|
||
hyprctl keyword monitor $INT, preferred,auto,1.5 2>/dev/null
|
||
hyprctl reload 2>/dev/null
|
||
fi
|