Repository navigation
Conversation
Single-battery UPower read reported only BAT0 on multi-battery machines. Percentage is now energy-weighted across packs, capacity and draw are summed, and remaining time follows the most urgent pack. No consumer changes: output keys and lines are unchanged. Closes omacom#7214, closes omacom#7897, closes omacom#8303, closes omacom#8504, closes omacom#8521, closes omacom#9026, closes omacom#9776, closes omacom#10244, closes omacom#11618, closes omacom#11990.
|
Tested this PR on real dual-battery hardware, and it fixes the bug. Hardware: ThinkPad T470s (internal BAT0 + a second pack in BAT1), Omarchy 4.0.4-1, tested at a6aee39. Raw sysfs: Before (installed 4.0.4-1, reads only BAT0): After (this PR): |
|
Thanks for testing this on real dual-battery hardware — that's exactly the machine class this targets. Your numbers line up with the intended aggregation: 30% energy-weighted across packs (matching UPower's own DisplayDevice), 43Wh summed capacity, 17W summed live draw, and time-to-full from the charging pack. The BAT0-only 28% / 0W read before is the bug in a nutshell. The detailed before/after makes review easy — appreciate it. |
|
Status check — no formal review on this one yet, though sebastien-debros already verified it on real dual-battery hardware: "Tested this PR on real dual-battery hardware, and it fixes the bug." Their test was on a ThinkPad T470s (internal BAT0 plus a second pack in BAT1) at Re-verified against current
Happy to take another look at anything, or to add coverage if there's a case the aggregation should handle. |
|
Reviewed against Charging time and thresholds are misread, on single-battery machines too.
I confirmed the shift by running the awk program and Remaining time follows the wrong pack. On ThinkPads the packs drain one after the other, so the earliest pack's time to empty is the time until handover, not until the machine dies: one pack at 10Wh draining at 10W beside an idle one holding 30Wh shows Nothing was run on a worker: with #10392 already carried forward for this bug, verifying this one would not change what the maintainer decides. The second opinion, Codex Medium, also ranked #10392 first and found the same parsing shift; it can read this review's reasoning, so that agreement is not guaranteed independent. It added two findings of its own: the partial sysfs sum above, and that single-battery percentage is now recalculated from energy rather than taken from UPower, which changes what single-battery machines display (the original test fixture reports 51% and this would show 49%, which is why that fixture had to change). This now waits on the maintainer, who decides between this and #10392. |
|
Thank you for this, @ansonboby. #10392 fixes the same problem in a way the review judged better, so this is closed in favour of it. If it does not cover your case, please say so there. Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent. |
Summary
omarchy-battery-statusread only the first UPower battery (grep BAT | head -n 1), so multi-battery machines (ThinkPads, Surface Book) showed one pack's charge as the whole machine.Now aggregates across every UPower battery: percentage energy-weighted like UPower's DisplayDevice (with mean fallback when energy fields are absent), capacity and draw summed (live sysfs
power_nowsummed acrossBAT*so the panel stays live), remaining time follows the most urgent pack, state prefers charging > discharging. Thresholds/cycles keep first-available. No consumer changes —--shellkeys and the human line are byte-identical in shape, so the power panel and low-battery notification inherit the fix.Test plan
test/shell.d/battery-status-test.sh: single-battery assertions kept (fixture made self-consistent for weighted math), plus a dual-battery section (40% + 60% packs) asserting 50% combined, 100Wh, 10W summed draw, 2h urgent-pack time. All pass;battery-test.shandbin-style-test.shunaffected.Closes #7214, closes #7897, closes #8303, closes #8504, closes #8521, closes #9026, closes #9776, closes #10244, closes #11618, closes #11990.