Disable laptop displays when external monitor is connected OR lid is closed. Works automatically with hotplug detection.
Three files:
- monitor-manager.sh - Script with laptop display configs and logic
- monitors.conf - Defines all displays + runs script on reload/lid events
- autoexec.conf - Runs script on startup + sets up hotplug detection
First, identify your displays:
hyprctl monitors | grep descriptionExample output:
description: BOE NE135A1M-NY1
description: ASUSTek COMPUTER INC PA27JCV T5LMSV003436
Save to ~/.config/hypr/scripts/monitor-manager.sh:
#!/bin/bash
# ===== CONFIGURATION =====
# Asus ProArt 27" 5K
EXTERNAL_DESC="ASUSTek COMPUTER INC PA27JCV"
# Framework 13, ThinkPad X1 Carbon Gen 8
LAPTOP_DISPLAYS=(
"BOE NE135A1M-NY1" # Framework 13
"AU Optronics 0x573D" # ThinkPad X1 Carbon Gen 8
)
LAPTOP_CONFIGS=(
"2880x1920@120, auto, 2, vrr, 1" # Framework 13
"1920x1080@60, auto, 1.25" # ThinkPad X1 Carbon Gen 8
)
# =========================
# Check lid state
LID_CLOSED=false
if grep -q closed /proc/acpi/button/lid/*/state 2>/dev/null; then
LID_CLOSED=true
fi
# Check for external
EXTERNAL_CONNECTED=false
if hyprctl monitors | grep -q "$EXTERNAL_DESC"; then
EXTERNAL_CONNECTED=true
fi
# Disable if external connected OR lid closed
if $EXTERNAL_CONNECTED || $LID_CLOSED; then
for display in "${LAPTOP_DISPLAYS[@]}"; do
hyprctl keyword monitor "desc:$display, disable" 2>/dev/null
done
else
for i in "${!LAPTOP_DISPLAYS[@]}"; do
hyprctl keyword monitor "desc:${LAPTOP_DISPLAYS[$i]}, ${LAPTOP_CONFIGS[$i]}" 2>/dev/null
done
fiMake it executable:
chmod +x ~/.config/hypr/scripts/monitor-manager.shDefine all displays and run script on every reload:
# Laptop displays - defined properly for when they should be enabled
monitor = desc:BOE NE135A1M-NY1, 2880x1920@120, auto, 2, vrr, 1
monitor = desc:AU Optronics 0x573D, 1920x1080@60, auto, 1.25
# External monitor
env = GDK_SCALE, 2
env = xx_color_management_v4, true
monitorv2 {
output = desc:ASUSTek COMPUTER INC PA27JCV T5LMSV003436
mode = 5120x2880@60
position = auto
scale = 2
}
# Run script after any reload to re-apply correct display state
exec = ~/.config/hypr/scripts/monitor-manager.sh
# Lid switches trigger script
bindl = , switch:on:Lid Switch, exec, ~/.config/hypr/scripts/monitor-manager.sh
bindl = , switch:off:Lid Switch, exec, ~/.config/hypr/scripts/monitor-manager.sh
# Run on startup
exec-once = ~/.config/hypr/scripts/monitor-manager.sh
# Hotplug detection (requires: pacman -S socat)
exec-once = socat -u UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do [[ "$line" =~ ^monitor ]] && ~/.config/hypr/scripts/monitor-manager.sh; doneScript runs on:
- Startup (via autoexec.conf)
- Any config reload (via
execin monitors.conf) - Lid open/close (via monitors.conf bindings)
- Monitor plug/unplug (via socat listener)
Logic:
- External connected OR lid closed → disable laptop displays
- Otherwise → enable laptop displays
The exec line ensures correct display state is re-applied whenever Hyprland reloads config for any reason.
Works across both Framework and ThinkPad - only applies configs for displays that are present.
I was using this, but it doesn't works when opening the lid after sleep/suspend. So I disabled it for now.