Skip to content

Fix power popup readings on multi-battery laptops - #17639

Open
blankdean wants to merge 2 commits into
omacom:quattrofrom
blankdean:fix/composite-battery-status
Open

blankdean wants to merge 2 commits into
omacom:quattrofrom
blankdean:fix/composite-battery-status

Conversation

@blankdean

@blankdean blankdean commented Nov 5, 2026 •

Copy link
Copy Markdown

What changes

Fix the power popup showing 0% while its icon and progress bar show a charged battery on multi-battery laptops.

On a ThinkPad X270, the internal BAT0 reports zero full capacity while the removable BAT1 is charged. The status command selected the first system battery; the icon and progress bar already use UPower's combined DisplayDevice.

Use DisplayDevice for combined battery readings and bind the popup percentage to the same live reading as its progress bar. Keep instantaneous kernel power readings and charge-limit calculations for one usable pack. With multiple packs, use UPower's combined rate and time estimate, and omit ambiguous per-pack cycle counts and thresholds. Ignore absent packs and firmware slots reporting zero full capacity.

No new dependencies, polling, or model-specific rules. The X270 is verified hardware; other machines with the same first-pack selection problem should benefit too.

Verification

  • Battery status regression suite passes, including existing Apple Silicon, arbitrary battery names, signed power, missing readings, charge-limit and translation cases.
  • Added coverage for unequal-capacity packs (70% combined versus a first-pack 50% or unweighted 62.5%), combined charging estimates, a zero-capacity internal slot, and removed packs. Fixtures include per-pack power, thresholds and cycle counts to catch accidental use of one pack's data.
  • Bash syntax and whitespace checks pass.
  • Ran the PR's shell on the X270 and inspected the panel: 99% combined charge, 19 Wh, 202 cycles. Restored the installed shell afterward. No unplug/discharge hardware test was performed.
  • The broad CLI suite passed. The previously started full shell suite is still running; no full-suite pass is claimed.

Screenshots

Before After (PR shell on the X270)
Popup selects empty internal pack and shows 0% Popup shows combined charge and valid capacity

UPower documents DisplayDevice as the composite source for desktop status displays: https://upower.freedesktop.org/docs/UPower.html#UPower.GetDisplayDevice

@blankdean
blankdean marked this pull request as ready for review November 5, 2026 04:46
@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR aligns battery readings across the power popup and bar.

  • Battery status reports the combined charge for usable battery packs.
  • The power popup’s large percentage follows its battery charge fraction.

No actionable issues were found. blankdean explicitly describes omitting per-pack cycle counts and thresholds on multi-pack machines as intentional. blankdean also states that no unplug/discharge hardware test was performed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Physical batteries] --> B[Skip absent and zero-capacity packs]
  B --> C{One usable pack?}
  C -->|Yes| D[Keep its kernel power reading and metadata]
  C -->|No| E[Omit per-pack metadata]
  F[UPower DisplayDevice] --> G[Combined charge and capacity]
  F --> H[Combined rate and time for multiple packs]
  G --> I[Battery status output]
  D --> I
  E --> I
  H --> I
  F --> J[Live popup percentage and progress bar]
Loading

Reviews (1) · Last reviewed commit: "Preserve combined battery time estimates..." · Reviewed by Greptile

@aholbreich

Copy link
Copy Markdown
Contributor

This is the same approach as #10392 (UPower's DisplayDevice for more than one pack), which is verified and merges cleanly. The part #10392 lacks is skipping packs with energy-full: 0 or present: no (your X270 case, and #13292). That would fit well as a small follow-up on top of #10392.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read the diff at 5e2fa9c21beaed464677e066bb0c30c050150762, the battery-status command and its power-panel consumers. Codex High (GPT-6) was the only technical reviewer. I classified this as a hardware compatibility fix, but the second classifier, deepseek-v4p1-flash via pi, returned no usable class, so classification remains unsettled.

No tests ran and no code changed. This is waiting for classification to be resolved before worker verification.

@omarchybot omarchybot added the bug Something isn't working label Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Classification is now agreed as a bug. Codex High (GPT-6) compared this head, 5e2fa9c21beaed464677e066bb0c30c050150762, with #10392, #13292 and #14861, and checked the battery command's panel and notification consumers. Opus 5.5 High and muse-wonder via pi, thinking high also reviewed the diffs. Both recommended retaining the older #10392 for the combined-reading fix: it uses the same combined source while preserving the single-pack data source. Independence between the reviews is not guaranteed.

This carries additional work worth preserving from @blankdean: empty/absent-pack filtering, keeping sysfs metadata on the selected usable pack, validating cycle counts, and binding the hero percentage to the same live value as the bar. I queued these improvements and their regression cases for #10392's own session to fold in with author credit. #13292 also covers phantom-pack selection, and #12058 covers script percentage rounding; those overlaps need to remain accounted for. Whether to omit thresholds and cycles on multi-pack machines remains a maintainer decision.

No tests ran and no code changed in this pass, because #10392 was selected as the competing fix to bring forward. This pull request remains open and waits on the maintainer.

omarchybot added a commit to calledtoconstruct/omarchy that referenced this pull request Nov 22, 2026
A removed pack may remain in UPower enumeration with power supply: yes. Counting it switches a single present pack to DisplayDevice and takes cycle counts and charge limits from the removed slot. Skip candidates explicitly marked absent, preserving the live sysfs path and metadata for the remaining pack. This carries the absent-pack check from omacom#17639 without changing the first-pack metadata policy or dropping zero-capacity packs.

Co-Authored-By: Dean Blank <blankdean@gmail.com>
Co-Authored-By: GPT-6 in Codex (effort unspecified) <noreply@openai.com>
Co-Authored-By: Opus 5.5 High <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants