Building a macOS app to know when my Mac is thermal throttling
4 months ago
- #macOS
- #thermal-throttling
- #SwiftUI
- The author built MacThrottle, a macOS app to monitor thermal throttling on M2 MacBook Air, especially when using demanding external displays.
- Thermal throttling occurs when the CPU usage is at 100% but power usage drops, making the system slow or unresponsive.
- Apple's ProcessInfo.thermalState and powermetrics provide thermal state data, but their granularity and states differ, making ProcessInfo less useful for detecting actual throttling.
- The author discovered that thermald writes thermal pressure data to the Darwin notification system (notifyd), allowing access without root privileges.
- MacThrottle was built as a SwiftUI menu bar app, showing thermal state via a thermometer icon with color changes from green to red.
- Initially, the app used a root helper with powermetrics but later switched to using thermald's IPC notifications for simplicity and security.
- Temperature and fan speed data are displayed in a compact graph, with CPU temperature and fan speed (if available) plotted over a 10-minute window.
- The app includes macOS notifications for state changes and can be set to launch at login using SMAppService.
- Due to lack of notarization, installing the app requires extra steps, and building from source is necessary for some Macs.