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>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ad023413c6
commit
63f147ef85
Executable
+17
@@ -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
|
||||||
@@ -31,7 +31,13 @@ poll_clamshell_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sync_clamshell_after_monitor_change
|
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
|
socat -U - "UNIX-CONNECT:$SOCKET" | while read -r event; do
|
||||||
case "$event" in
|
case "$event" in
|
||||||
|
|||||||
Reference in New Issue
Block a user