feat: reflect Low Power Mode in the menu bar battery icon - #22
Conversation
|
"Hey! @srimanachanta Just a quick heads-up: I've submitted 6 modular PRs (PRs #17 through #22) to break down a larger set of features and make the review process much easier for you. Because a few of these PRs touch the same core files (like Once you merge a PR, if GitHub flags any of my remaining open PRs with conflicts, just let me know or leave them be—I will actively monitor the repo and locally rebase my remaining branches against your updated
Thanks for maintaining Stasis! Let me know if you need any adjustments. |
- Remove TOCTOU gap: seed isLowPowerModeEnabled inside startObservingPowerMode() instead of stored-property default - Pass object: ProcessInfo.processInfo to notification sequence to avoid waking on unrelated posts - Hop mutation back to MainActor.run in observer task - Cancel powerModeObservation in deinit - Add comment clarifying red (critical) takes priority over yellow (low power) -- intentional behavior - Expand #Preview with Low Power Mode section (yellow for normal, red for critical <=10%)
|
Hey @srimanachanta! I've addressed all the review comments. Here's a summary of what was updated:
Let me know if anything needs further adjustment! |
This pull request adds support for detecting and displaying macOS Low Power Mode status in the battery indicator. The main changes include tracking Low Power Mode in the view model, observing system notifications for changes, and updating the battery indicator's color when Low Power Mode is enabled.
Low Power Mode support:
isLowPowerModeEnabledtoMenuViewModelto track the current Low Power Mode status, and initialized it usingProcessInfo.processInfo.isLowPowerModeEnabled.startObservingPowerMode()inMenuViewModelto listen for.NSProcessInfoPowerStateDidChangenotifications and updateisLowPowerModeEnabledaccordingly. This ensures the app responds to system changes in Low Power Mode. [1] [2]UI updates:
StatusBarContentViewto pass the newisLowPowerModeEnabledproperty toBatteryIndicatorView, enabling the UI to reflect Low Power Mode status.BatteryIndicatorViewto accept theisLowPowerModeEnabledparameter and change the battery fill color to yellow when Low Power Mode is active.