Skip to content

Show every battery in the power panel on laptops with more than one - #22006

Open
imekinox wants to merge 1 commit into
omacom:quattrofrom
imekinox:power-panel-per-battery
Open

imekinox wants to merge 1 commit into
omacom:quattrofrom
imekinox:power-panel-per-battery

Conversation

@imekinox

@imekinox imekinox commented Dec 6, 2026

Copy link
Copy Markdown

What changes

omarchy-battery-status read 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.sh and test/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):

Before

After (combined reading, one row per battery):

After

Written with Claude Fable 5.2 via Claude Code.

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>
@greptile-apps

greptile-apps Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[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.

Findings

  1. P2 Charging time uses wrong limit ▶
  2. P2 Unknown charge becomes zero ▶
  3. P2 Test files remain ▶
Fix 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.

Summary

Adds combined battery readings and individual battery rows to the power panel.

  • The power panel shows a combined reading and a row for each battery.

Reviews (1) · Last reviewed commit: "Show every battery in the power panel on..." · Reviewed by Greptile

Comment on lines +140 to +144
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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Comment on lines +148 to +153
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) }')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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.

@omarchybot omarchybot added the enhancement New feature or request label Dec 6, 2026
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

Development

Successfully merging this pull request may close these issues.

2 participants