From f7d3f3428801276aeb06e55d4916a8cb64ebcb0f Mon Sep 17 00:00:00 2001 From: Al Johri Date: Tue, 23 Jun 2026 15:42:14 -0400 Subject: [PATCH] Disable internal display on lid close even without external monitor The lid-close binding short-circuits when no external monitor is attached, and omarchy-hyprland-monitor-internal refuses to disable the panel when it's the only output. Together, this means closing the lid on a laptop with no external display leaves the internal panel scanning out at full backlight. Users who configure logind to keep the system running through lid close (HandleLidSwitchExternalPower=ignore, common for headless / background-task workflows) lose the only path that would have blanked the panel, costing several watts of idle draw. Introduce bin/omarchy-hw-lid-closed as the lid-state primitive, mirroring the omarchy-hw-clamshell pattern from the quattro branch. Relax the "only active display" guard in omarchy-hyprland-monitor-internal so the off/recover paths permit disabling the panel when the lid is closed, and drop the omarchy-hw-external-monitors short-circuit from the lid bindl so the script's own guard is the single decision point. Desktops without an ACPI lid sensor fall through as "lid open", so the existing safety behavior is preserved. --- bin/omarchy-hw-lid-closed | 11 +++++++++++ bin/omarchy-hyprland-monitor-internal | 4 ++-- default/hypr/bindings/utilities.lua | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 bin/omarchy-hw-lid-closed diff --git a/bin/omarchy-hw-lid-closed b/bin/omarchy-hw-lid-closed new file mode 100755 index 0000000000..8e03f9656f --- /dev/null +++ b/bin/omarchy-hw-lid-closed @@ -0,0 +1,11 @@ +#!/bin/bash + +# omarchy:summary=Returns true when the laptop lid is closed +# omarchy:hidden=true + +for state in /proc/acpi/button/lid/*/state; do + [[ -r $state ]] || continue + [[ $(< "$state") == *"closed"* ]] && exit 0 +done + +exit 1 diff --git a/bin/omarchy-hyprland-monitor-internal b/bin/omarchy-hyprland-monitor-internal index 6b72c2bd9f..6948928851 100755 --- a/bin/omarchy-hyprland-monitor-internal +++ b/bin/omarchy-hyprland-monitor-internal @@ -18,7 +18,7 @@ on() { } off() { - if ! omarchy-hw-external-monitors; then + if ! omarchy-hw-external-monitors && ! omarchy-hw-lid-closed; then omarchy-notification-send -g 󰍹 "Can't disable the only active display" exit 1 fi @@ -31,7 +31,7 @@ off() { } recover() { - if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled $TOGGLE; then + if ! omarchy-hw-external-monitors && ! omarchy-hw-lid-closed && omarchy-hyprland-toggle-enabled $TOGGLE; then omarchy-hyprland-toggle $TOGGLE off fi } diff --git a/default/hypr/bindings/utilities.lua b/default/hypr/bindings/utilities.lua index e167256d63..c9cd1e6466 100644 --- a/default/hypr/bindings/utilities.lua +++ b/default/hypr/bindings/utilities.lua @@ -32,7 +32,7 @@ o.bind_toggle("SUPER + CTRL + I", "Toggle locking on idle", "idle") o.bind_toggle("SUPER + CTRL + N", "Toggle nightlight", "nightlight") o.bind("SUPER + CTRL + Delete", "Toggle laptop display", "omarchy-hyprland-monitor-internal toggle") o.bind("SUPER + CTRL + ALT + Delete", "Toggle laptop display mirroring", "omarchy-hyprland-monitor-internal-mirror toggle") -o.bind("switch:on:Lid Switch", nil, "omarchy-hw-external-monitors && omarchy-hyprland-monitor-internal off", { locked = true }) +o.bind("switch:on:Lid Switch", nil, "omarchy-hyprland-monitor-internal off", { locked = true }) o.bind("switch:off:Lid Switch", nil, "omarchy-hyprland-monitor-internal on", { locked = true }) o.bind("PRINT", "Screenshot", "omarchy-capture-screenshot")