Skip to content

perf: update the menu bar angle only when needed - #17

Open
Jah-yee wants to merge 1 commit into
sumimakito:mainfrom
Jah-yee:codex/subscribe-angle-title
Open

Jah-yee wants to merge 1 commit into
sumimakito:mainfrom
Jah-yee:codex/subscribe-angle-title

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Sep 11, 2026 •

Copy link
Copy Markdown

Problem

StatusItemController ran a 250 ms timer for its entire lifetime, even when Show angle in menu bar was off (the default). Most timer firings therefore read the angle and touched no UI.

Change

  • observe the visibility preference instead of polling it
  • subscribe to angle changes only while the title is enabled
  • format and de-duplicate whole-degree titles before writing AppKit state
  • preserve the previous 4 Hz update ceiling with a latest-value throttle
  • publish the initial title immediately, then cancel and clear it immediately when disabled

The lid sensor's own polling is unchanged; this only removes hidden status-title wakeups and redundant title assignments.

Edge cases

  • the persisted enabled state produces a title during controller initialization
  • repeated on/off toggles replace, rather than accumulate, subscriptions
  • cancellation drops any throttled trailing value before the title is cleared
  • weak captures and explicit cancellation avoid retaining the status controller

Validation

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