From 63f147ef85ebea23a249f24d6897d55619d6a09e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 20 Jul 2026 08:09:07 -0700 Subject: [PATCH] Only run the clamshell poll on laptops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit omarchy-hyprland-monitor-watch ran poll_clamshell_state() every 2s for the whole session, and each pass forks omarchy-hyprland-monitor-clamshell plus its hyprctl/jq/monitor-* children. Clamshell (lid) handling can only ever apply to a machine with a lid, so on desktops and VMs this was pure churn — the single largest remaining source of idle process wakeups (~3 forks/sec on an otherwise idle desktop). Gate the poll behind a new omarchy-hw-laptop helper (lid button, or a laptop DMI chassis type as a fallback). The event-driven socat watch on Hyprland monitor add/remove is unchanged, so monitor hotplug still reconciles everywhere; only the periodic lid poll is now laptop-only. Verified on a desktop: steady-state omarchy-hyprland-* forks drop from ~3/sec to zero, socat watch still present. Co-Authored-By: Claude Fable 5 --- bin/omarchy-hw-laptop | 17 +++++++++++++++++ bin/omarchy-hyprland-monitor-watch | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-hw-laptop 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