diff --git a/bin/omarchy-hw-laptop b/bin/omarchy-hw-laptop new file mode 100755 index 00000000..0ffbeeb3 --- /dev/null +++ b/bin/omarchy-hw-laptop @@ -0,0 +1,17 @@ +#!/bin/bash + +# omarchy:summary=Returns true when running on a laptop (has a lid or laptop chassis). + +# A lid switch is the definitive signal for clamshell-capable hardware. +for state in /proc/acpi/button/lid/*/state; do + [[ -e $state ]] && exit 0 +done + +# Fall back to the DMI chassis type for laptops that don't expose an ACPI lid +# button. 8=Portable 9=Laptop 10=Notebook 14=Sub Notebook 30=Tablet +# 31=Convertible 32=Detachable. +case $(< /sys/class/dmi/id/chassis_type 2>/dev/null) in +8 | 9 | 10 | 14 | 30 | 31 | 32) exit 0 ;; +esac + +exit 1 diff --git a/bin/omarchy-hyprland-monitor-watch b/bin/omarchy-hyprland-monitor-watch index bd2a2a1e..4353d300 100755 --- a/bin/omarchy-hyprland-monitor-watch +++ b/bin/omarchy-hyprland-monitor-watch @@ -31,7 +31,13 @@ poll_clamshell_state() { } sync_clamshell_after_monitor_change -poll_clamshell_state & + +# The socat watch below already reconciles clamshell state on monitor +# hotplug. The periodic poll only exists to catch laptop-lid transitions, +# so there is nothing for it to do on a machine that isn't a laptop. +if omarchy-hw-laptop; then + poll_clamshell_state & +fi socat -U - "UNIX-CONNECT:$SOCKET" | while read -r event; do case "$event" in