omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Battery panel shows only the first battery on dual-battery laptops (ThinkPad BAT0 + BAT1)

Open TobiasVeiga00 opened this issue 1 month ago • 5 comments

System details

Lenovo ThinkPad T480, Intel Core i5-8350U, Intel UHD Graphics 620, Omarchy 4.0.4-1 (dual battery: BAT0 internal ~18 Wh + BAT1 external ~45 Wh)

What's wrong?

On laptops with two batteries (e.g. ThinkPad T480/T470/T580 with internal BAT0 + hot-swappable external BAT1), the Power panel in the Omarchy shell shows the charge of the first battery only, while the bar widget percentage shows the real combined charge. The two numbers disagree.

omarchy-battery-status picks the first UPower device matching BAT:

# /usr/share/omarchy/bin/omarchy-battery-status:21
battery=$(upower -e 2>/dev/null | grep BAT | head -n 1)

The bar widget (plugins/panels/power/Panel.qml) uses UPower.displayDevice, which is the combined device. The panel's hero percentage, size, rate and time come from omarchy-battery-status --shell, which only reads BAT0.

Steps to reproduce

  1. Use a laptop with two batteries, where BAT0 is full and BAT1 is partially charged.
  2. Enable showPercentage on omarchy.power (the bar shows e.g. 86%).
  3. Click the battery widget to open the Power panel.

Expected

The panel shows the same combined charge as the bar (86%, 63 Wh), with combined rate and time remaining.

Actual

The panel shows only BAT0: 100%, 18Wh, state fully-charged, while BAT1 (45 Wh, 80%, charging) is ignored.

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage   # 100%
$ upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep percentage   # 80%
$ upower -i /org/freedesktop/UPower/devices/DisplayDevice | grep percentage  # 85.8%
$ omarchy-battery-status --shell | head -1                                  # percentage 100%

Suggested fix

Prefer the combined DisplayDevice and fall back to the first BAT:

battery=$(upower -e 2>/dev/null | grep -m1 DisplayDevice)
[[ -z $battery ]] && battery=$(upower -e 2>/dev/null | grep BAT | head -n 1)

I tested this locally: it reports 86% / 63 Wh with combined rate and time. Charge thresholds are still read from BAT* sysfs as before. Note that cycles and the threshold lines still come from the first battery (BAT*/... | head -1), which is acceptable but could also be made per-battery.

TobiasVeiga00 avatar Oct 10 '26 00:10 TobiasVeiga00

Debug log (omarchy-debug --no-sudo, MAC/IP addresses and username redacted): https://logs.omarchy.org/ULdkRF

TobiasVeiga00 avatar Oct 10 '26 00:10 TobiasVeiga00

Confirming on a second ThinkPad T480 (BAT0 internal LGC 01AV489 + BAT1 external Celxpert 01AV424, Omarchy 4.0.4-1, UPower 1.91.3, kernel 7.2.5).

The firmware charges/discharges the packs one after another, so whichever pack is idle reports Not charging / power_now 0. With BAT0 idle while BAT1 charges, the panel shows 5% · Holding at 75-80% · 0W / 15Wh while the combined DisplayDevice is charging, 21.6 W, 35.7 Wh, 1.6 h to full.

#14861 fixes the main issue and the locale problem (with de_DE.UTF-8, upower prints time to full: 1,6 hours, which the awk parser turns into 1h instead of 1h 36m). Two things it still leaves open on dual-battery machines:

  1. Charge cycles: cat BAT*/cycle_count | head -1 only shows BAT0 (76 here; BAT1 has 143). Listing every battery (e.g. 76 / 143) would be more honest. The regression test in #14861 currently asserts the single-battery value.
  2. Charge limit: thresholds are read from upower -i first. UPower 1.91 reports charge-start-threshold: 75% / charge-end-threshold: 80% even though charge thresholds are not enabled and sysfs says charge_control_start_threshold 0 / charge_control_end_threshold 100. So the panel shows a "Charge limit 75-80%" that the firmware does not enforce. Reading charge_control_*_threshold from sysfs first (what the EC actually applies) avoids that.

For reference, I'm running a cloned power plugin locally with a script that uses the DisplayDevice, LC_ALL=C, sums power_now across all BAT*, lists all cycle counts and prefers sysfs thresholds. Since then the panel matches the bar.

marcangermann avatar Oct 12 '26 14:10 marcangermann

Thanks for the clear repro and the debug log — the grep BAT | head -n 1 vs UPower.displayDevice mismatch is exactly the dual-battery split.

#14861 (Prefer combined DisplayDevice in battery status) looks like the direct fix for this issue. There is also overlap with #13292 (phantom BAT0 on dual-bay ThinkPads) and the stacked #12789 work on DisplayDevice poisoning, so those three should stay lined up when one of them lands.

jandrusk avatar Oct 12 '26 18:10 jandrusk

Confirming this isn't ThinkPad-specific: same behaviour on a Dell Pro Rugged 14 (RB14250) with two internal packs (BAT0 + BAT1, both DELL HT6PT5BU), Omarchy 4.0.4-1, UPower 1.91.3.

The packs charge one after the other, so with BAT0 charging at 17% and BAT1 idle at 3%, the bar showed ~10% (DisplayDevice) while the panel showed 17% / 44Wh / 1h 30m. The combined DisplayDevice was 89Wh, 3h 17m to full.

I can also confirm the charge-limit point above on Dell hardware: upower -i reports charge-start-threshold: 75% / charge-end-threshold: 80%, but sysfs on BAT0 has charge_control_start_threshold 50 / charge_control_end_threshold 90, and charge_types is [Adaptive]. Dell only applies those thresholds in Custom mode, so the panel's "Charge limit 75-80%" isn't what the firmware does here either. BAT1 doesn't expose thresholds at all.

A local clone using the DisplayDevice, summing power across all BAT*, and listing cycles per pack (12 / 22) makes the panel match the bar, which lines up with #14861 plus the cycles suggestion above.

JoNatGeekFiWiFi avatar Oct 17 '26 02:10 JoNatGeekFiWiFi

This is the same bug as #6885, which is older and still open, so I'm closing this one in favour of it. Both report the power panel showing only the first battery while the bar shows the combined charge, on the same ThinkPad T480 layout, with the same cause. Checked against quattro at be54892f: bin/omarchy-battery-status (lines 44-52) still takes the first battery UPower lists that powers the machine, while the bar reads UPower's combined DisplayDevice. On a dual-battery laptop that first battery is BAT0, so the panel describes BAT0 alone. Nothing on quattro has changed that yet.

The open fixes are tracked against #6885 too: #10392 already closes both issues, and #14861 and #15204 close this one. The maintainer is picking between them, so closing this loses none of them.

The two extra findings in this thread are covered elsewhere. Cycle count coming from BAT0 alone is the same first-battery choice, and #15204 and #12789 list it per pack. The panel trusting UPower's 75-80% charge-start and charge-end thresholds over the sysfs charge_control_*_threshold values the firmware actually applies is #7374.

Nothing was run for this. It needs a dual-battery laptop, which a worker can't stand in for, and the cause is visible in the source. Two models classified it separately as a bug. Codex at medium effort, asked separately, agreed this is the same report as #6885, though that agreement isn't independent proof. If this turns out to be a different problem from #6885, it can be reopened.

omarchybot avatar Oct 22 '26 07:10 omarchybot