Skip to content

feat(system-monitor): add CPU and memory usage gauges in notch header#1083

Open
teszerrakt wants to merge 1 commit intoTheBoredTeam:devfrom
teszerrakt:feature/system-monitor-dev
Open

feat(system-monitor): add CPU and memory usage gauges in notch header#1083
teszerrakt wants to merge 1 commit intoTheBoredTeam:devfrom
teszerrakt:feature/system-monitor-dev

Conversation

@teszerrakt
Copy link

@teszerrakt teszerrakt commented Mar 4, 2026

Summary

Adds an optional System Monitor feature that displays CPU and memory usage as circular gauge rings in the notch header area. Resolves #1082.

  • Polls CPU and memory stats every 3 seconds using macOS Mach kernel APIs (zero new dependencies)
  • Color-coded gauge rings: green/yellow/red based on configurable thresholds
  • Click-to-show popover with detailed stats and "Open Activity Monitor" button
  • Disabled by default — user opts in via Settings > System Monitor

Screenshots

System Monitor in Notch Header & Popover

Screenshot 2026-03-05 at 05 25 29

Settings View

Screenshot 2026-03-05 at 05 25 47

Changes

New Files

File Description
boringNotch/managers/SystemMonitorManager.swift Singleton manager polling CPU (host tick deltas) and memory (VM stats — active+wired+compressed) via Mach APIs. Cached host port with proper deallocation in deinit.
boringNotch/components/SystemMonitor/SystemMonitorView.swift Two 18×18pt circular gauge rings with SF Symbol icons, ScaleButtonStyle, click-to-show popover (SystemMonitorMenuView), reusable GaugeRingView subview, color extension.
boringNotch/components/Settings/Views/SystemMonitorSettingsView.swift Settings page with enable/disable toggle and live CPU/memory stats preview.

Modified Files

File Change
Constants.swift Added showSystemMonitor Defaults key (Bool, default: false)
BoringHeader.swift Conditionally show SystemMonitorView() before mirror button
SettingsView.swift Added sidebar link + detail routing for System Monitor settings
BoringViewModel.swift Added isSystemMonitorPopoverActive property + reset in close()
ContentView.swift Added popover flag to 3 notch-close guards + .onChange observer
project.pbxproj Added PBXFileReference, PBXBuildFile, PBXGroup, PBXSourcesBuildPhase entries
Localizable.xcstrings Added localization entries for System Monitor strings

Design Decisions

  • Mach APIs only — uses host_statistics / host_statistics64 directly, no dependencies on sysctl or third-party libs
  • CPU calculation — delta-based tick comparison between polls (user+system+nice vs total), not instantaneous snapshot
  • Memory calculation(active + wired + compressed) / total physical matches Activity Monitor's "Memory Used"
  • Color thresholds — CPU: green <50%, yellow 50–80%, red >80%; Memory: green <70%, yellow 70–85%, red >85%
  • Hover persistence — follows the battery popover pattern (isSystemMonitorPopoverActive flag prevents notch auto-close)
  • Resource managementmach_host_self() port cached and deallocated in deinit to prevent Mach port leak

Testing

  • Gauges display correct CPU/memory percentages (compare with Activity Monitor)
  • Color transitions work at threshold boundaries
  • Popover opens/closes correctly, notch stays open while popover is active
  • Feature is disabled by default, toggle in Settings works
  • Timer starts/stops properly when feature is toggled on/off
  • No memory leaks or Mach port leaks (check with Instruments)

Add optional system monitor displaying CPU and memory usage as circular
gauge rings in the notch header area. Uses macOS Mach kernel APIs to
poll host_statistics every 3 seconds with no external dependencies.

- SystemMonitorManager: singleton polling CPU ticks and VM stats
- SystemMonitorView: color-coded gauge rings (green/yellow/red) with
  click-to-show popover for detailed stats and Activity Monitor shortcut
- SystemMonitorSettingsView: toggle + live preview in Settings
- Popover hover persistence prevents notch auto-close while open
- Disabled by default, configurable via Settings > System Monitor

Closes TheBoredTeam#1082
@teszerrakt teszerrakt marked this pull request as ready for review March 4, 2026 22:56
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