Repository navigation
Conversation
omarchy-battery-status picked the first BAT* device from `upower -e` and read percentage, state, capacity, rate, time, and cycles from it directly. On hardware with more than one battery (e.g. a ThinkPad with a Power Bridge bay), the first-enumerated device can be an idle/empty one, so the panel shows a correct icon and meter (both driven by UPower's DisplayDevice elsewhere in the shell) alongside a completely wrong detail row — in the reported case, 0% with 0W/0Wh and no time remaining, while the battery was actually near full. Read UPower's DisplayDevice instead, the same aggregate source the bar icon and panel meter already use, so the detail row matches what's on screen. Charge threshold is genuinely per-ACPI-device policy rather than a per-battery reading (UPower reports the same value on every battery object), so that lookup still queries an individual device. The live sysfs wattage refinement and cycle count now sum/max across every BAT* device instead of reading a single native-path, since an idle battery reporting 0 doesn't affect either.
There was a problem hiding this comment.
Pull request overview
Uses UPower’s aggregate DisplayDevice to report accurate multi-battery status.
Changes:
- Aggregates battery details and live wattage.
- Reports the highest cycle count.
- Adds multi-battery regression coverage.
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 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-battery-status |
Uses aggregate battery data and multi-device telemetry. |
test/shell.d/battery-status-test.sh |
Updates the single-battery UPower fixture. |
test/shell.d/battery-status-multi-battery-test.sh |
Adds a dual-battery regression test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| grep -Fx $'rate\t10.8W' <<<"$shell_output" >/dev/null || fail "multi-battery status sums live sysfs wattage across every battery" "$shell_output" | ||
| grep -Fx $'threshold\t75-80%' <<<"$shell_output" >/dev/null || fail "multi-battery status still reports the charge threshold" "$shell_output" |
There was a problem hiding this comment.
Good catch — fixed in e60f7f8. Both fixture batteries now carry distinguishable nonzero telemetry (BAT0: 4.2W / 12 cycles, BAT1: 10.8W / 347 cycles), and the test asserts the summed rate (15W) and the max cycle count (347), so a regression to picking a single device or the first cycle_count now fails.
…ttery test The dual-battery fixture had BAT0 contribute 0W and no cycle_count file, so the rate assertion couldn't tell summing every device apart from just picking BAT1, and the max-cycle-count behavior wasn't exercised at all. Give both batteries distinguishable nonzero values (4.2W/12 cycles and 10.8W/347 cycles) and assert the sum (15W) and the maximum (347). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Guuwe3XxYQGY1A9rJizAim
|
Tested this PR's Hardware state at test time, straight from sysfs:
The aggregate half of the fix works. Same machine, same moment:
The empty Two things the PR leaves behind, both visible on this machine: 1. 2. The bogus no TLP installed and nothing else setting a limit, yet the PR still emits which matches every machine ( That's #9586 / #7374 rather than this PR's remit, so entirely fair to leave it — but dual-battery hardware makes it markedly easier to hit, which is why it shows up here. Neither of those blocks the fix this PR is making. The aggregate numbers are correct on this hardware where Testing and write-up done with Claude Code. |
|
Automated duplication check: this pull request looks similar to #10392, which covers the same battery-status multi-battery aggregation. I keep that one open and close this one to consolidate review. If you feel this is the wrong decision, please open the PR again with a note on the difference. |

omarchy-battery-statuspicks the firstBAT*device fromupower -eand reads percentage, state, capacity, rate, time, and cycles from it directly. On hardware with more than one battery (e.g. a ThinkPad with a Power Bridge bay), the first-enumerated device can be an idle/empty one — so the panel shows a correct icon and meter (both driven by UPower's DisplayDevice elsewhere in the shell) alongside a completely wrong detail row: in the reported case, 0% with 0W/0Wh and no time remaining while the battery was actually near full.Fix
BAT*device (DisplayDevice has nonative-pathof its own); an idle battery reading 0 doesn't affect the total, so this is a no-op on single-battery hardware.Tests
Added
test/shell.d/battery-status-multi-battery-test.sh, which stubs a dual-battery machine (idle BAT0 with all-zero fields, real BAT1) and verifies the status output reports the aggregate reading rather than BAT0's zeroes. Both battery test files pass; the full shell suite shows no new failures versusquattro.🤖 Generated with Claude Code
https://claude.ai/code/session_01Guuwe3XxYQGY1A9rJizAim