Files
dotfiles-xps/hypr/scripts/lid_handler.sh
2026-02-24 22:44:05 +01:00

20 lines
794 B
Bash
Executable File

#!/bin/bash
# ~/.config/hypr/scripts/lid_handler.sh
if [[ "$1" == "close" ]]; then
# Lid closed: disable laptop screen if any DP-* monitor is present
# Using 'all' to detect monitors even if they are currently disabled
if hyprctl monitors all | grep -q "Monitor DP-"; then
hyprctl keyword monitor "eDP-1, disable" # Disable laptop display
# Enable all detected DP-* monitors
for monitor in $(hyprctl monitors all | grep "Monitor DP-" | awk '{print $2}'); do
hyprctl keyword monitor "$monitor, enable"
done
systemd-run --user --on-active=5s systemctl --user restart waybar.service hyprpaper.service
fi
elif [[ "$1" == "open" ]]; then
# Lid opened: re-enable laptop screen
hyprctl keyword monitor "eDP-1, enable"
fi