Skip to content

Warn about a low battery at 20% as well as 10% - #20264

Open
itxkarthik wants to merge 3 commits into
omacom:quattrofrom
itxkarthik:low-battery-warn-at-20
Open

itxkarthik wants to merge 3 commits into
omacom:quattrofrom
itxkarthik:low-battery-warn-at-20

Conversation

@itxkarthik

Copy link
Copy Markdown

The only low-battery warning fires at 10% or below, once per discharge. A pack whose gauge reads high (an uncalibrated or aftermarket replacement, or voltage sag under load) can power off above that, so no warning is ever shown. In #20084 the pack cut out at a reported 12%.

The battery service now warns once at 20% and once more at 10%. 20% is UPower's own PercentageLow default, so the shell's first warning lines up with where UPower already reports the battery as low.

  • The notifiedLowBattery boolean becomes lowBatteryWarnedAt, the lowest threshold warned at this discharge.
  • As before, charging does not re-arm a warning, so an AC flap at a threshold still warns once. Climbing back above a threshold re-arms it and the ones below it.
  • A drop straight past both thresholds warns once, at the lower one.
  • The notification itself is unchanged: same normal toast and 30-second timeout as Send the low battery warning as a normal toast that goes after 30 seconds #16562, and the battery-low hook still gets the percentage, now at each warning.

Fixes #20084

Related: #17881 and #17387 also edit shouldWarnLowBattery / the battery service, so whichever lands second needs a small rebase.

Test plan

  • bash test/shell.d/battery-test.sh passes; the updated cases fail on quattro.
  • New cases cover the 20% warning at a reported 12%, one warning per threshold through a full 30% to 2% discharge, and the 10% warning re-arming after recovering above it.

A pack whose gauge reads high, such as an uncalibrated replacement, can cut out above 10%, so the only warning never came. The shell now warns once at 20%, UPower's own PercentageLow, and once more at 10%. Each level is latched through AC flaps as before, and climbing back above one re-arms it.

Fixes omacom#20084
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The earlier warning-queue issue still needs attention before merging.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The PR changes when battery warnings appear in the desktop shell.

The earlier warning-queue issue still needs attention before merging.

Summary

The PR adds low-battery warnings at 20% and 10%.

  • The battery service warns at 20% and again at 10%.
  • A battery warning waits for the current warning command to finish.

Reviews (7) · Last reviewed commit: "Test that a low-battery warning due duri..." · Reviewed by Greptile

A battery-low hook still running from the 20% warning made the 10% one return early, and its level was already latched, so it was lost for the rest of the discharge. Hold it and send it when the running warning exits.
@chessing234

Copy link
Copy Markdown
Contributor

both of your commits are in #21013. the 20% and 10% thresholds stayed, and a warning that arrives while the previous hook is running is still queued. the dismiss path from #20286 uses that same latch instead of a second boolean. @dhh @omarchybot if 21013 lands, this can close as superseded.

@greptile-apps

greptile-apps Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

The 10% warning can come due while the 20% warning's omarchy-battery-low is
still running. battery-test.sh now loads the battery service in a fixture,
with a stub that records each level and keeps running briefly, and checks
that 20 and then 10 are both sent. The fixture runs without a system bus,
so the machine's own battery cannot add a warning. These checks come last
because require_quickshell skips the rest of the file without a compositor.
@itxkarthik
itxkarthik force-pushed the low-battery-warn-at-20 branch from 5f1cc38 to 672d20a Compare December 1, 2026 05:56
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

3 participants