power: color battery indicator by charge state - #11291
Open
heyssh wants to merge 1 commit into
Open
Conversation
Add threshold-based colors to the battery indicator (bar icon, panel hero icon, and progress bar fill): - Below 20% charge: tint red - Below 5% charge: red, plus an exclamation mark appended to the battery glyph - Charging: tint green, taking priority over the low-battery red since a battery recovering from a low charge isn't an alarm state batteryIsLow/batteryIsCritical are added to Model.js as pure percentage checks, following the file's existing testable-helper style. Panel.qml exposes them plus a shared batteryIndicatorColor property so all three visual battery elements stay in sync. Colors are literal hex values for now (#e5484d / #30a46c); happy to switch to semantic Color tokens if the theme exposes them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Omarchy Power
Bar widget showing battery, power profile, and system stats. Backed by
UPowerfor battery state and a handful ofomarchy-*shell commands forprofiles and system stats.
Files
manifest.jsonbar-widget, entry pointPanel.qml).Panel.qmlModel.jsPanel.qml. Kept separate so the logic is testable without a running shell.Battery indicator states
The battery is drawn in three places that all share one color: the bar
icon, the panel's hero icon, and the progress bar fill.
batteryLowColor)!appended to the battery glyphbatteryChargingColor)Notes on precedence:
is good news, not an alarm, so the green tint takes priority over red
whenever
root.chargingis true. "Charging" here already excludesFullyChargedand an active charge-threshold hold (batteryFlowIdle),matching the rest of the file's existing
chargingproperty.!mark is percentage-only. It's driven purely bybatteryIsCritical(< 5%), independent of charge state — so it canstill show up while charging back from a very low percentage.
The threshold checks live in
Model.jsasbatteryIsLow(device)andbatteryIsCritical(device), following the file's existing style of thin,pure wrappers around
batteryFraction.Panel.qmlexposes them asbatteryLow/batteryCritical, and combines them withcharginginto asingle
batteryIndicatorColorproperty that every visual battery elementbinds to.
Testing without draining the battery
To visually check the low/critical states without waiting for a real
laptop to discharge, temporarily hardcode the two state properties in
Panel.qml< 20% charge:
< 5% charge:
Actively charging (see below):