Skip to content

mute-switch: back off on missing audio sink and curb idle wakeups - #213

Closed
tcballard wants to merge 2 commits into
OrchardLinux:mainfrom
tcballard:perf-mute-switch-backoff
Closed

tcballard wants to merge 2 commits into
OrchardLinux:mainfrom
tcballard:perf-mute-switch-backoff

Conversation

@tcballard

Copy link
Copy Markdown
Contributor

Summary

  • On boards with a hardware mute switch (gpio-keys KEY_MUTE) whose audio output is not brought up yet, omarchy-mute-switch retried wpctl set-mute @DEFAULT_AUDIO_SINK@ every 2 s indefinitely — burning CPU (1m38s over 1.5 d on iPhone 6) and writing 360 KB of repeated Translate ID error: '-1' lines into RAM-backed $XDG_RUNTIME_DIR/omarchy-mute-switch.log.
  • Adds exponential backoff to Follower.failed() (2 s up to 60 s, reset immediately on any switch movement or successful mute) and deduplicates consecutive identical stderr error messages.
  • Lengthens idle select liveness timeout (1 s → 5 s) and newly-connected keyboard rescan interval (2 s → 10 s).

Testing

  • Extended tests/test_mute_switch.py with backoff cap/reset and deduplicated error-logging tests (22/22 pass).

When no default audio sink exists (boards without audio brought up yet),
omarchy-mute-switch retried wpctl every 2 s forever, burning CPU and writing
hundreds of kilobytes of identical 'Translate ID error: -1' lines to the
RAM-backed runtime log. It also scanned /sys/class/input every 2 s and woke
every 1 s to check compositor liveness.

Back off consecutive set_mute failures exponentially (2 s up to 60 s, reset
immediately on any switch move or success), deduplicate repeated stderr lines,
and lengthen idle wake/keyboard-scan intervals to 5 s / 10 s.

Assisted-by: LLM
@tcballard

Copy link
Copy Markdown
Contributor Author

Superseded by #222, which replaces the Python mute-switch daemon with a small C99 helper including this retry backoff and deduplicated error logging.

@tcballard tcballard closed this Dec 2, 2026
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.

1 participant