Repository navigation
Conversation
omarchy-battery-status read only the first battery, so on a ThinkPad with an internal and a removable battery the panel showed that one's charge, size and time left instead of the machine's. It now adds the batteries up and gives the panel a line for each. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Confidence Score: 4/5
[Medium impact] The change affects battery readings in the power panel and battery status command. The PR appears safe to merge, with non-blocking fixes recommended for charging estimates, incomplete readings, and test cleanup. FindingsFix with agent prompt### Issue 1
bin/omarchy-battery-status:140-144
The combined charging estimate still uses only the first battery's charge limit. If `BAT0` holds 16Wh of 20Wh at an 80% limit and `BAT1` charges from 30Wh toward 60Wh at 10W, the new totals produce 1h 48m instead of 3h. Add each battery's remaining energy up to its own limit rather than applying the first battery's limit to the combined capacity.
### Issue 2
bin/omarchy-battery-status:148-153
The new sum turns a missing energy reading into zero. The script already supports missing energy by using UPower's time estimate. If two batteries provide capacity and percentage but omit energy, the combined percentage becomes 0%, and the time estimate disappears. Keep track of missing readings and avoid replacing them with a measured zero.
### Issue 3
test/shell.d/battery-status-test.sh:373
This replaces the earlier exit trap but drops `hwdb_dir`. Every successful run now leaves that temporary directory and its fixtures behind. Keep `hwdb_dir` in the cleanup list when adding `dual_dir`.
```suggestion
trap 'rm -rf "$tmp_dir" "$hold_dir" "$hwdb_dir" "$dual_dir"' EXIT
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds combined battery readings and individual battery rows to the power panel.
Reviews (1) · Last reviewed commit: "Show every battery in the power panel on..." · Reviewed by Greptile |
| read -r energy energy_full energy_full_design power_rate_raw < <(awk \ | ||
| -v energy="$energy" -v full="$energy_full" -v design="$energy_full_design" -v rate="${power_rate_raw:-0}" -v other_rate="${other_rate:-0}" ' | ||
| /^ *energy:/ { energy += $2 } | ||
| /energy-full:/ { full += $2 } | ||
| /energy-full-design:/ { design += $2 } |
There was a problem hiding this comment.
Charging time uses wrong limit
The combined charging estimate still uses only the first battery's charge limit. If BAT0 holds 16Wh of 20Wh at an 80% limit and BAT1 charges from 30Wh toward 60Wh at 10W, the new totals produce 1h 48m instead of 3h. Add each battery's remaining energy up to its own limit rather than applying the first battery's limit to the combined capacity.
Prompt To Fix With AI
This is a comment left during a code review.
Path: bin/omarchy-battery-status
Line: 140-144
Comment:
**Charging time uses wrong limit**
The combined charging estimate still uses only the first battery's charge limit. If `BAT0` holds 16Wh of 20Wh at an 80% limit and `BAT1` charges from 30Wh toward 60Wh at 10W, the new totals produce 1h 48m instead of 3h. Add each battery's remaining energy up to its own limit rather than applying the first battery's limit to the combined capacity.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| print energy + 0, full + 0, design + 0, rate + other_rate | ||
| }' <<<"$other_info") | ||
| done | ||
|
|
||
| if awk -v full="$energy_full" 'BEGIN { exit !(full > 0) }'; then | ||
| percentage=$(awk -v energy="$energy" -v full="$energy_full" 'BEGIN { print int(energy / full * 100) }') |
There was a problem hiding this comment.
The new sum turns a missing energy reading into zero. The script already supports missing energy by using UPower's time estimate. If two batteries provide capacity and percentage but omit energy, the combined percentage becomes 0%, and the time estimate disappears. Keep track of missing readings and avoid replacing them with a measured zero.
Prompt To Fix With AI
This is a comment left during a code review.
Path: bin/omarchy-battery-status
Line: 148-153
Comment:
**Unknown charge becomes zero**
The new sum turns a missing energy reading into zero. The script already supports missing energy by using UPower's time estimate. If two batteries provide capacity and percentage but omit energy, the combined percentage becomes 0%, and the time estimate disappears. Keep track of missing readings and avoid replacing them with a measured zero.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| # Two batteries (a ThinkPad's internal and removable pair): the reading is the | ||
| # machine's, and each battery keeps a line of its own. | ||
| dual_dir=$(mktemp -d) | ||
| trap 'rm -rf "$tmp_dir" "$hold_dir" "$dual_dir"' EXIT |
There was a problem hiding this comment.
This replaces the earlier exit trap but drops hwdb_dir. Every successful run now leaves that temporary directory and its fixtures behind. Keep hwdb_dir in the cleanup list when adding dual_dir.
| trap 'rm -rf "$tmp_dir" "$hold_dir" "$dual_dir"' EXIT | |
| trap 'rm -rf "$tmp_dir" "$hold_dir" "$hwdb_dir" "$dual_dir"' EXIT |
Prompt To Fix With AI
This is a comment left during a code review.
Path: test/shell.d/battery-status-test.sh
Line: 373
Comment:
**Test files remain**
This replaces the earlier exit trap but drops `hwdb_dir`. Every successful run now leaves that temporary directory and its fixtures behind. Keep `hwdb_dir` in the cleanup list when adding `dual_dir`.
```suggestion
trap 'rm -rf "$tmp_dir" "$hold_dir" "$hwdb_dir" "$dual_dir"' EXIT
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
What changes
omarchy-battery-statusread only the first battery, so on a laptop with two (ThinkPad T440–T480 with an internal and a removable battery) the power panel showed that one's charge, size and time left instead of the machine's. The bar, which uses UPower's display device, showed a different number.The script now adds the batteries up, and the panel lists each one under the combined reading. A laptop with one battery is unchanged. No new translation strings: each row is the battery's name and its reading.
Addresses discussions #8678 and #13208 (the per-battery half).
Verification
On a ThinkPad T470 (BAT0 + BAT1): the panel went from 87% / 21Wh to 25% / 88Wh, matching
upower -i /org/freedesktop/UPower/devices/DisplayDevice.Ran
test/shell.d/battery-status-test.shandtest/shell.d/power-test.sh, both with new two-battery cases; both pass.Not run:
./test/all. The panel was checked as a cloned user plugin rather than from a full worktree shell, which is why the history chart is empty in the "after" capture (clones cannot read the battery service). Only tested with two batteries where one is idle and one discharging, on battery power.Screenshots
Before (first battery only):
After (combined reading, one row per battery):
Written with Claude Fable 5.2 via Claude Code.