Skip to content

Port arch-ipad-auto-brightness daemon to C99 - #230

Merged
henrikklee merged 3 commits into
OrchardLinux:mainfrom
tcballard:perf-auto-brightness-c
Dec 6, 2026
Merged

henrikklee merged 3 commits into
OrchardLinux:mainfrom
tcballard:perf-auto-brightness-c

Conversation

@tcballard

Copy link
Copy Markdown
Contributor

Replaces the 866-line Python 3 desktop/configuration/auto-brightness daemon and CLI with a zero-dependency C99 binary (desktop/configuration/auto-brightness.c, ~57 KB ELF, linked only with -lm, POSIX PTY without -lutil).

  • Reduces resident memory on devices with an ambient light sensor from ~14 MiB (Python 3) to ~0.5 MiB, and cuts control-center/settings toggle latency.
  • Preserves the ALS log-lux curve, median + asymmetric exponential smoother, hysteresis/interval policy, smoothstep perceptual gamma ramp, compare-and-set powerd Unix socket IPC, IIO/mock/PTY monitor-sensor sources, SIGHUP config reload, and all CLI commands (on|off|toggle|status|enabled|available|--list|--probe).
  • Updated tests/test_auto_brightness.py to run all 8 tests (including a real Unix-socket mock powerd) against the compiled C binary.

Tested: 37/37 pass (test_auto_brightness.py, test_package_staging.py, test_package.py).

tcballard and others added 2 commits December 2, 2026 11:25
Replaces the 866-line Python 3 desktop/configuration/auto-brightness daemon
and CLI with a zero-dependency C99 binary (desktop/configuration/auto-brightness.c,
~57 KB ELF, ~0.5 MiB RSS, linked only with -lm).

Preserves the ALS log-lux curve, median + asymmetric exponential smoother,
hysteresis/interval policy, smoothstep perceptual gamma ramp, compare-and-set
powerd Unix socket IPC, IIO/mock/PTY monitor-sensor sources, SIGHUP config
reload, and all CLI commands (on|off|toggle|status|enabled|available|--list|--probe).

Assisted-by: LLM
henrikklee pushed a commit to grierj/omarchy-a that referenced this pull request Dec 6, 2026
At desktop idle the shell was spawning 8 processes per second because
panels/power/Status.qml ran a 1-second omarchy-battery-status timer
(which also forked awk) across four live instances (bar, lock screen,
control center, and power panel). RotationLock.qml likewise ran four
separate 2-second polling timers and four startup busctl probes.

- Compute omarchy-battery-status size and rate in pure bash without awk
  (guarding optional sysfs reads, octal leading zeros, and integer width),
  keeping the charge_full -> mAh fallback for charge-reporting gauges.
- Share one UPower-signal-driven BatteryStatus singleton (30 s fallback,
  coalesced concurrent refreshes, on-demand refresh when Control Center
  or Power panel opens).
- Share one RotationLockState singleton watching the config directory
  (and its parent for directory replacement) with one busctl probe and a
  shared setLocked() helper used by both Control Center and Display
  settings.

[Orchard: cut to the battery and rotation-lock readers, with both of the
PR's commits folded into one; the auto-brightness and omarchy-powerd
wakeup changes are left out, since those daemons are being ported to C
(OrchardLinux#230, OrchardLinux#231), where the same fixes belong.]

Assisted-by: LLM
# Conflicts:
#	CHANGELOG.md
#	Makefile
#	desktop/install-tree
#	release/audit.py
#	tests/package_tree.py
#	tests/test_package.py
@henrikklee
henrikklee merged commit 58dbb1e into OrchardLinux:main Dec 6, 2026
11 checks passed
@henrikklee

Copy link
Copy Markdown
Contributor

Merged, thank you Tom! With this one, all six helpers from your series are C now (#222, #227–#231). That's a big chunk of memory back on every board, and the old Python test suites keep guarding the behaviour. Lovely work.

On your branch we merged main in, so auto-brightness builds next to the other C helpers, and we added the changelog line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants