Files
omarchycn/bin/omarchy-hw-laptop
David Heinemeier HanssonandClaude Fable 5 63f147ef85 Only run the clamshell poll on laptops
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 <noreply@anthropic.com>
2026-07-20 08:09:07 -07:00

18 lines
543 B
Bash
Executable File

#!/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