omarchy/bin/comarchy-disable-internal-monitor
2025-08-26 20:55:40 +02:00

36 lines
1.2 KiB
Plaintext
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# ~/.local/bin/hyprautointernal.sh
# Disable the laptop panel (eDP1) 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