Skip to content

feat: customizable menu bar with percentage badges and launch-at-login - #5

Open
soupman99 wants to merge 1 commit into
wiscaksono:mainfrom
soupman99:feature/menu-bar-percentage-badges
Open

soupman99 wants to merge 1 commit into
wiscaksono:mainfrom
soupman99:feature/menu-bar-percentage-badges

Conversation

@soupman99

Copy link
Copy Markdown

Adds two new toggles to the settings sheet for customizing the menu bar item:

  • Show percentages in menu bar — switch between the bundled OpenCode logo (default) and three colored percentage pills showing rolling/weekly/monthly usage. Pills use full-saturation green/yellow/red backgrounds with white text and 13pt semibold monospaced digits.
  • Launch at login — register the app via SMAppService.mainApp so it starts automatically when the user logs in.

Implementation

  • New MenuBarRenderer utility renders the menu bar item to NSImage so per-character foreground colors survive the MenuBarExtra label pipeline (which otherwise drops foregroundStyle on Text and clips multi-view containers to the first child).
  • New LaunchAtLogin service wraps SMAppService.mainApp; idempotent setEnabled(_:), throws on rejection, reads/writes system status directly (no UserDefaults cache to drift).
  • New MenuBarStyle enum (.logo / .badges) persisted via AppSettings; the App reads it via @AppStorage so the menu bar reacts instantly when the setting changes.

Notes

  • Thresholds: 0–74 green, 75–89 yellow (darker goldenrod so white text stays legible), 90–100 red.
  • Verified locally: swift build, swift test (12/12 pass), swiftformat --lint . all clean.

Add a settings sheet with two new toggles for customizing the menu bar item:
- "Show percentages in menu bar" — switch between the bundled OpenCode
  logo (default) and three colored percentage pills (rolling/weekly/monthly)
- "Launch at login" — register the app via SMAppService.mainApp so it
  starts automatically when the user logs in

Implementation notes:
- MenuBarRenderer renders to NSImage so per-character foreground colors
  survive the MenuBarExtra label pipeline (which drops foregroundStyle
  and clips multi-view containers). 13pt semospaced semibold text on
  rounded-rect pills tinted green/yellow/red at full saturation with
  white text. Falls back to a darkGray "—" pill until stats arrive.
- LaunchAtLogin wraps SMAppService.mainApp; idempotent setEnabled(_:)
  throws on rejection, reads/writes system status directly (no
  UserDefaults cache to drift).
- MenuBarStyle enum (.logo / .badges) persisted via AppSettings; the
  App reads it via @AppStorage so the menu bar reacts instantly.
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