Skip to content

Turn the bar battery icon red and blinking when low - #8036

Open
thooams wants to merge 13 commits into
omacom:quattrofrom
thooams:battery-low-indicator
Open

thooams wants to merge 13 commits into
omacom:quattrofrom
thooams:battery-low-indicator

Conversation

@thooams

@thooams thooams commented Aug 24, 2026 •

Copy link
Copy Markdown

Summary

Adds a three-tier visual low-battery indicator to the Quickshell bar, escalating as charge drops while discharging:

Threshold Bar icon
≤ 10% yellow (matches the existing omarchy-battery-low notification threshold)
≤ 5% red — matches UPower's own PercentageCritical default
≤ 2% red and blinking — matches UPower's PercentageAction default, the point where the system forces a suspend/hibernate

Each tier is a superset of the next (danger implies warning, critical implies both), so the bar only ever shows its reddest active tier.

Also:

  • Adds a reusable blinking property to WidgetButton, pulsing the drawn color's alpha (not the item's opacity — bar text/glyphs render with Text.NativeRendering, which doesn't composite with an animated ancestor opacity, so an opacity-driven pulse silently never showed on screen; verified live, before/after, by diffing captured frames a full animation period apart).
  • Adds a warning semantic color (from the theme's yellow/color3, alongside the existing urgent/red) since the bar previously had no non-red "pay attention" tint.
  • Rounds the low-battery comparison the same way the notification does, so both switch together instead of disagreeing by a percentage point at the boundary.
  • Dismisses the low-battery toast notification as soon as the charger is plugged in, instead of leaving it up for its full 30s timeout after the user has already acted on it.

Addresses long-standing requests for a visual low-battery indicator (#1502, #3066, #1798, #1213, discussions #2343, #4473). A prior attempt at colored battery icons (#2808) was closed for scope/quality reasons on the old waybar setup; this targets the current Quickshell-based bar and reuses its existing semantic-color plumbing instead of hardcoding colors per theme.

screenshot-2026-08-24_20-02-27 screenshot-2026-08-24_19-59-21 screenshot-2026-08-24_19-56-30

Test plan

  • test/shell.d/power-test.sh — unit tests for isBatteryLow() at all three thresholds, plus regex checks on the Panel.qml wiring
  • test/shell.d/battery-test.sh — regex checks on the plug-in dismiss wiring
  • ./test/shell — full suite green aside from 4 pre-existing, unrelated failures
  • Visual check in the running bar on real hardware: captured before/after frames confirming the blink actually renders, and let the physical battery drain through 10% → 7% (yellow), 5% (red), and 2% (blinking) to confirm each tier live; also confirmed the low-battery toast disappears immediately on plugging in

Adds a reusable `blinking` property to WidgetButton (drives a looping
opacity pulse without fighting the existing opacity binding) and wires
it up alongside the existing `active`/`activeColor` mechanism on the
power panel's bar icon, keyed off a new isBatteryLow() check in
Model.js. Threshold matches the existing omarchy-battery-low
notification (10%, discharging).
Copilot AI balanced review requested due to automatic review settings August 24, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a visual low-battery warning to the Quickshell bar.

Changes:

  • Adds reusable blinking support to WidgetButton.
  • Turns the battery indicator urgent-colored and blinking at low charge.
  • Adds low-battery model and wiring tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
shell/Ui/WidgetButton.qml Adds opacity pulsing support.
shell/plugins/panels/power/Panel.qml Activates the warning state at low battery.
shell/plugins/panels/power/Model.js Determines whether battery charge is low.
test/shell.d/power-test.sh Tests low-battery logic and panel wiring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread shell/plugins/panels/power/Model.js Resolved
Comment thread shell/Ui/WidgetButton.qml Resolved
thooams and others added 7 commits August 24, 2026 19:32
isBatteryLow() compared the raw percentage fraction against the threshold
while the omarchy-battery-low notification rounds first, so a level like
10.4% triggered the notification but left the bar icon uncolored.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
The pulse animated a blinkOpacity property that fed into the item's
opacity, but bar text/glyphs render with Text.NativeRendering, which
doesn't composite with an animated ancestor opacity — only color changes
are drawn. The color did flip (active/urgent), so the red tint showed but
the pulse never did. Verified live: before the fix, captured frames a full
period apart were pixel-identical; after, they visibly alternate.

Drive the pulse through the drawn color's alpha instead, via a shared
blinkedColor() helper (reusing Util.alpha() rather than reimplementing it)
that both the label Text and BarIconButton's icon glyph call. Also apply
blinkOpacity directly to BarIconButton's iconComponent Loader, since
Loader-hosted content isn't NativeRendering text and still composites
opacity normally, and disable the label's color Behavior while blinking so
it doesn't fight the per-frame pulse.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
The bar indicator is a persistent visual, not a one-shot warning, so give
it a lower bar than the omarchy-battery-low notification (10%) and reserve
it for the final stretch before shutdown.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
A single red+blinking state didn't give enough warning before shutdown.
Escalate through three thresholds while discharging: 10% turns the bar
icon yellow (matching the existing omarchy-battery-low notification
threshold), 5% turns it red, and 2% adds the blink — lining up with
UPower's own PercentageCritical (5) and PercentageAction (2) defaults,
the point at which the system forces a suspend/hibernate.

Adds a warning semantic color (from the theme's yellow/color3, alongside
the existing urgent/red) since the bar had no non-red "pay attention" tint.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
The warning notification otherwise lingers for its full 30s timeout even
after the user has already acted on it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
isBatteryLow() additionally required device.state === Discharging, a
stricter condition than root.discharging (isPresent && onBattery) used
everywhere else in Panel.qml. device.state can lag onBattery by a poll
cycle right after a plug event (already covered by the "stale discharging
state" test above), so the three battery tiers could stay uncolored for a
beat while the rest of the panel already read as on-battery. Drop the
state check and trust onBattery, like the rest of the panel does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
The low-battery toast's title was hardcoded independently in both
bin/omarchy-battery-low (send) and Service.qml (dismiss on plug-in), with
nothing tying them together — an edit to one would silently break the
dismiss without any test catching it. Cross-reference them in comments and
assert the two strings match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R9toPoRnj7WKNtKhVZDMcr
Resolve two conflicts with upstream's no-animations mode, which wrapped
the same animation durations this branch edited in Style.duration():
- WidgetButton.qml: keep the !root.blinking guard on the label's color
  Behavior and take the Style.duration(160) duration.
- Bar.qml: take Style.duration(420) on the existing Behaviors and apply
  it to the Behavior on warning this branch adds.

Also hold the low-battery blink still under Style.reduceMotion, the way
upstream's other looping pulses and spinners do. The critical tier still
shows in the urgent color; it just does not animate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds visual warning states to the battery indicator.

The PR appears safe to merge; no new actionable issue was found.

What we checked:

  • Charging keeps the warning visible: isBatteryLow returns false on AC, so all three warning levels turn off.
  • Color animation hides the blink: WidgetButton disables its color animation while blinking. OpticalGlyph draws its assigned color directly.

Summary

Adds three low-battery tiers to the bar: yellow at 10%, red at 5%, and blinking red at 2%, while on battery.

  • Carries the warning color through themes and cloned widgets.
  • Pulses the drawn text color instead of ancestor opacity.
  • Dismisses the recharge toast on plug-in and guards queued dismissals after unplugging.
  • The three earlier, unnumbered findings are addressed in the current code. No new actionable issue was established.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Battery changes] --> B{On battery and present?}
  B -->|No| C[Normal icon]
  B -->|Yes| D{Rounded charge}
  D -->|Above 10 percent| C
  D -->|6 to 10 percent| E[Warning color]
  D -->|3 to 5 percent| F[Urgent color]
  D -->|2 percent or below| G[Urgent color and blink]
  H[Charger plugged in] --> I[Dismiss recharge toast]
  J[Warning command finishes on AC] --> I
Loading

Reviews (5) · Last reviewed commit: "Merge branch 'quattro' into battery-low-..." · Reviewed by Greptile

Comment thread shell/plugins/panels/power/Panel.qml Resolved
thooams and others added 2 commits October 6, 2026 22:50
…oast

Address the two review findings on the low-battery indicator:

- A power widget cloned with `omarchy plugin clone omarchy.power` gets a
  PluginBarApi rather than the host bar, and that facade had no `warning`
  color, so the clone could not show the yellow tier. Add the property
  and mirror it from the bar like `urgent`.
- Plugging in while the low-battery notification was still being sent
  let the dismiss run before the toast existed, leaving it up for its
  full timeout. Dismiss again once the send finishes if the charger is
  in, and queue a dismiss requested while one is already in flight
  instead of dropping it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve one conflict in shell/plugins/bar/Bar.qml: upstream switched the
bar color Behaviors from Easing.InOutCubic to Easing.OutCubic on the same
lines where this branch adds a Behavior on warning. Take OutCubic on the
existing Behaviors and apply it to the warning one so all four bar colors
ease the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thooams and others added 2 commits October 7, 2026 23:35
A dismiss queued while another was in flight replayed unconditionally, so
unplugging before it ran took down the new low-battery warning. Drop the
queued dismiss on unplug and replay it only while still on AC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants