Skip to content

mute-switch: replace Python daemon with a small C99 helper - #222

Merged
henrikklee merged 4 commits into
OrchardLinux:mainfrom
tcballard:perf-mute-switch-c
Dec 6, 2026
Merged

henrikklee merged 4 commits into
OrchardLinux:mainfrom
tcballard:perf-mute-switch-c

Conversation

@tcballard

Copy link
Copy Markdown
Contributor

Summary

  • Replaces the persistent Python 3 omarchy-mute-switch daemon (~9.8 MiB RSS + swap on 1 GB iPhone 6) with a zero-dependency C99 binary (desktop/configuration/mute-switch.c, ~31 KB ELF / ~0.5 MiB RSS) compiled alongside wvkbd and wtype in Makefile, staged by desktop/install-tree, and architecture-audited by release/audit.py.
  • Preserves full behaviour: kernel unsigned long-width capabilities/key bitmap parsing (32-bit armv7h and 64-bit aarch64), 300 ms settle/debounce, suspend/resume stability via EVIOCGKEY, atomic PID flag in $XDG_RUNTIME_DIR/omarchy-mute-switch, and external keyboard KEY_MUTE forwarding.
  • Includes exponential retry backoff (2 s → 60 s, reset on switch move or success), deduplicated stderr logging when no audio output exists yet, and 5 s / 10 s idle liveness / keyboard rescan intervals.
  • Supersedes mute-switch: back off on missing audio sink and curb idle wakeups #213.

Testing

  • Compiled cleanly with cc -O2 -Wall -Wextra -Werror -std=c99.
  • Updated tests/test_mute_switch.py to compile and test the C binary directly (5/5 pass).
  • tests/test_package_staging.py (7/7) and tests/test_package.py (22/22) pass.

The persistent Python 3 omarchy-mute-switch daemon consumed ~9.8 MiB
(RSS + swap) on 1 GB boards just to poll evdev for KEY_MUTE on gpio-keys
and external keyboards.

Replace it with a zero-dependency C99 binary (~31 KB ELF, ~0.5 MiB RSS)
compiled alongside wvkbd and wtype in Makefile and audited by release/audit.py.
Preserves full behaviour (kernel-width bitmap parsing, 300 ms settle/debounce,
suspend/resume stability, PID flag, external keyboard Mute forwarding) plus
exponential retry backoff (2 s to 60 s) and deduplicated stderr logging when
no audio sink exists.

Assisted-by: LLM
mute-switch.c includes linux/input.h, which macOS lacks; the repository's
suite is green on both, and a test that needs what a Mac lacks skips with
its reason (AGENTS.md).

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

Copy link
Copy Markdown
Contributor

Merged, thank you Tom! Another Python daemon gone, and the back-off is a nice touch.

On your branch we merged main in (it now builds next to the C power daemon from #231) and moved the changelog line from the 0.4.6 section up to Unreleased. #213, which this replaces, was already closed. Next up: #227.

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