How rurza/batfi works
BatFi is a macOS battery-management app for Apple Silicon that lets users set charging limits and temporarily override them, including charging to 100% or discharging. The app’s main workflow runs from its menu-bar controls and settings into charging policy, which acts through system clients and a privileged helper; the UI also presents battery and power information. Onboarding, notifications, charts, and energy-use monitoring are distinct capabilities. Some subsystem links are based on the SOURCE INDEX or README because their implementation excerpts were not supplied.
Main entry points: App.swift BatFi app · ChargingManager.swift Charging policy · MenuContent.swift Menu content · StatusItemManager.swift Menu bar
Components 21
App and Controls
- BatFi app
BatFiKit/Sources/App/App.swift - Settings
BatFiKit/Sources/Settings/Settings.swift - Onboarding
BatFiKit/Sources/Onboarding/Onboarding.swift - App shortcuts
App/AppShortcuts.swift - Menu bar
BatFiKit/Sources/AppCore/StatusItemManager.swift - Menu content
BatFiKit/Sources/AppCore/MenuContent.swift
Battery Management
- Charging policy
BatFiKit/Sources/AppCore/ChargingManager.swift - Charging modes
BatFiKit/Sources/AppShared/AppChargingMode.swift - Notifications
BatFiKit/Sources/Notifications/NotificationsManager.swift - MagSafe indicator
BatFiKit/Sources/AppCore/MagSafeColorManager.swift - Persistence
BatFiKit/Sources/Clients/Persistence.swift
Helper and System
- Helper connection
BatFiKit/Sources/App/HelperConnectionManager.swift - Helper client
BatFiKit/Sources/Clients/HelperClient.swift - XPC service
BatFiKit/Sources/Shared/XPCService.swift - Privileged helper
BatFiKit/Sources/Server/Server.swift
Battery Insights
- Power state
BatFiKit/Sources/AppShared/PowerState.swift - Battery information
BatFiKit/Sources/Shared/BatteryInfo.swift - Power charts
BatFiKit/Sources/PowerCharts/ChartsView.swift - Energy usage
BatFiKit/Sources/HighEnergyUsage/HighEnergyUsageView.swift
Other components
- Mac user
- macOS battery services
Connections 24
- Mac user → BatFi app: uses
- BatFi app → Onboarding: presents
BatFiKit/Sources/App/App.swift - BatFi app → Charging policy: starts
BatFiKit/Sources/App/App.swift - BatFi app → Menu bar: starts
BatFiKit/Sources/App/App.swift - BatFi app → Settings: opens
BatFiKit/Sources/App/App.swift - Mac user → Settings: configures
BatFiKit/Sources/Settings/Settings.swift - Mac user → Menu bar: controls
BatFiKit/Sources/AppCore/StatusItemManager.swift - Menu bar → Menu content: renders
BatFiKit/Sources/AppCore/StatusItemManager.swift - Menu content → Battery information: displays
BatFiKit/Sources/AppCore/MenuContent.swift - Menu content → Power charts: displays
BatFiKit/Sources/AppCore/MenuContent.swift - Menu content → Energy usage: displays
BatFiKit/Sources/AppCore/MenuContent.swift - Menu bar → Charging policy: invokes overrides
BatFiKit/Sources/AppCore/StatusItemManager.swift - Charging policy → Charging modes: sets mode
BatFiKit/Sources/AppCore/ChargingManager.swift - Charging policy → Power state: observes
BatFiKit/Sources/AppCore/ChargingManager.swift - BatFi app → Notifications: starts
BatFiKit/Sources/App/App.swift - BatFi app → MagSafe indicator: starts
BatFiKit/Sources/App/App.swift - BatFi app → Helper connection: checks helper
BatFiKit/Sources/App/App.swift - Helper connection → Helper client: checks health
BatFiKit/Sources/App/HelperConnectionManager.swift - Charging policy → macOS battery services: controls charging
- Helper client → XPC service: communicates
- Privileged helper → XPC service: serves
- Charging policy → Persistence: stores state
- App shortcuts → Charging policy: requests actions
- Power state → Battery information: informs display