How tomheaton/menustats works
MenuStats is a macOS menu-bar monitor. At launch, its AppKit delegate starts a two-second refresh loop, reads CPU, memory, and SMC sensor data, then updates the status item and dropdown with current values and three-minute graphs. The dropdown also ranks app memory use and links to Activity Monitor. The sampled sources show the principal collectors and presentation components; the operating-system interfaces are external. Relationships shown here are limited to calls visible in the excerpts.
Main entry points: main.swift App delegate · Stats.swift CPU stats · SMC.swift Sensor readings · Graph.swift Graph rendering
Components 10
Menu Bar App
- App delegate
Sources/main.swift
System Collection
- CPU stats
Sources/Stats.swift - Memory stats
Sources/Stats.swift - App memory ranking
Sources/Stats.swift - Sensor readings
Sources/SMC.swift - SMC access
Sources/SMC.swift
Display
- Graph rendering
Sources/Graph.swift
Other components
- Mac user
- macOS APIs
- Activity Monitor
Connections 12
- Mac user → App delegate: uses
README.md - App delegate → CPU stats: reads ticks
Sources/main.swift - App delegate → CPU stats: computes usage
Sources/main.swift - App delegate → Memory stats: reads
Sources/main.swift - App delegate → Sensor readings: reads
Sources/main.swift - App delegate → App memory ranking: ranks apps
Sources/main.swift - App delegate → Graph rendering: updates graphs
Sources/main.swift - App delegate → macOS APIs: opens Activity Monitor
Sources/main.swift - SMC access → macOS APIs: calls IOKit
Sources/SMC.swift - Sensor readings → SMC access: reads keys
Sources/SMC.swift - CPU stats → macOS APIs: reads host stats
Sources/Stats.swift - Memory stats → macOS APIs: reads VM stats
Sources/Stats.swift