How srimanachanta/stasis works
Stasis is a macOS menu-bar battery monitor and charging controller for Apple Silicon MacBooks. On launch, the app initializes battery services, reads system and SMC metrics, evaluates charging policy, and presents live status and controls in the menu bar and settings. Charging changes are sent through an XPC daemon to hardware-facing SMC code. The graph also preserves the dashboard, power-flow visualization, settings, and privileged helper roles. Relationships are limited to the supplied excerpts, SOURCE INDEX references, and README; unsampled subsystem details are not inferred.
Main entry points: BatteryService.swift Battery service · AppDelegate.swift App startup · MenuViewModel.swift Menu view model · Helper.swift SMC reader helper
Components 25
App and presentation
- App startup
Stasis/AppDelegate.swift - Menu bar status
Stasis/StatusBarManager.swift - Battery menu
Stasis/Views/MenuBuilder.swift - Menu view model
Stasis/ViewModels/MenuViewModel.swift - Battery indicator
Stasis/Views/BatteryIndicatorView.swift - Power flow diagram
Stasis/Views/PowerSankeyView.swift - Settings window
Stasis/Controllers/SettingsWindowController.swift - Settings panels
Stasis/Views/Settings
Battery monitoring
- Battery metrics
Stasis/Models/BatteryMetrics.swift - Battery service
Stasis/Services/BatteryService.swift - IOKit monitoring
Stasis/Services/IOKitService.swift - SMC reader connection
Stasis/Services/SMCReaderConnection.swift - System information
Stasis/Services/SystemService.swift
Charging control
- Charging policy
Stasis/Services/ChargeManager.swift - Charging helper manager
Stasis/Services/ChargingHelperManager.swift - Charging XPC protocol
ChargingHelper/ChargingHelperProtocol.swift
Privileged hardware access
- Reader helper entry
Helper/main.swift - SMC reader helper
Helper/Helper.swift - Reader XPC protocol
Helper/HelperProtocol.swift - Charging daemon entry
ChargingHelper/main.swift - Charging daemon
ChargingHelper/ChargingHelper.swift - SMC battery access
SMCPower/SMCBattery.swift - SMC adapter access
SMCPower/SMCAdapter.swift
Other components
- Mac user
- macOS power and notification APIs
Connections 35
- Mac user → App startup: launches
Stasis/AppDelegate.swift - App startup → Battery service: initializes
Stasis/AppDelegate.swift - App startup → Charging policy: creates
Stasis/AppDelegate.swift - App startup → Menu view model: creates
Stasis/AppDelegate.swift - App startup → Battery menu: builds
Stasis/AppDelegate.swift - App startup → Settings window: creates
Stasis/AppDelegate.swift - App startup → Menu bar status: creates
Stasis/AppDelegate.swift - Menu bar status → Menu view model: reads
Stasis/StatusBarManager.swift - Menu bar status → Battery indicator: hosts
Stasis/StatusBarManager.swift - Battery menu → Menu view model: reads
Stasis/Views/MenuBuilder.swift - Battery menu → Settings window: opens
Stasis/Views/MenuBuilder.swift - Battery menu → Power flow diagram: shows
Stasis/Views/MenuBuilder.swift - Menu view model → Battery service: observes
Stasis/ViewModels/MenuViewModel.swift - Menu view model → Charging policy: observes
Stasis/ViewModels/MenuViewModel.swift - Menu view model → System information: reads
Stasis/ViewModels/MenuViewModel.swift - Settings window → Settings panels: hosts
Stasis/Controllers/SettingsWindowController.swift - Mac user → Menu bar status: views
README.md - Mac user → Settings panels: configures
README.md - Battery service → IOKit monitoring: starts monitoring
Stasis/Services/BatteryService.swift - Battery service → SMC reader connection: uses
Stasis/Services/BatteryService.swift - Battery service → SMC reader helper: requests SMC reads
Stasis/Services/BatteryService.swift - Battery service → Battery metrics: updates
Stasis/Services/BatteryService.swift - Charging policy → Battery service: evaluates and commands
Stasis/Services/ChargeManager.swift - Battery service → Charging helper manager: uses
Stasis/Services/BatteryService.swift - Charging helper manager → Charging XPC protocol: connects through
Stasis/Services/ChargingHelperManager.swift - Reader helper entry → SMC reader helper: instantiates
Helper/main.swift - SMC reader helper → Reader XPC protocol: implements
Helper/Helper.swift - SMC reader helper → SMC battery access: reads and probes
Helper/Helper.swift - SMC reader helper → SMC adapter access: reads and probes
Helper/Helper.swift - Charging daemon entry → Charging daemon: instantiates
ChargingHelper/main.swift - Charging daemon → Charging XPC protocol: implements
ChargingHelper/ChargingHelper.swift - Charging daemon → SMC battery access: controls charging
ChargingHelper/ChargingHelper.swift - Charging daemon → SMC adapter access: controls LED
ChargingHelper/ChargingHelper.swift - Battery service → macOS power and notification APIs: uses IOKit
Stasis/Services/BatteryService.swift - Charging policy → macOS power and notification APIs: asserts sleep and notifies
Stasis/Services/ChargeManager.swift