omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Battery percent in the top bar shows only BAT0

Open vcelletti opened this issue 3 months ago • 10 comments

System details

Thinkpad T480

What's wrong?

While both batteries are detected not every part of the battery icon module works as expected.

  • static battery shows what seems an overall percentage
  • opening the battery panel pop up in the top right corner shows only bat0 (no bat1)
  • double clicking on the bar shows the correct percent (both) in the top bar.

Thanks for your amazing work!

vcelletti avatar Aug 14 '26 19:08 vcelletti

Same machine (ThinkPad T480, Omarchy 4.0.0-1, Hyprland 0.56.2). Confirmed the icon and the panel are reading different things.

Bar icon uses Quickshell UPower.displayDevice (shell/plugins/panels/power/Panel.qml). That is UPower's composite device, energy-now / energy-full across both packs.

Panel details come from omarchy-battery-status --shell, which does upower -e | grep BAT | head -n 1 and therefore always inspects BAT0 only. Size, cycles, rate, time-to-empty, and the 94% in the popup are that one cell.

Measured just now:

Device Energy Full Percent State
BAT0 (LGC 01AV421, internal) 23.5 Wh 25.0 Wh 94% discharging
BAT1 (Sony 01AV427, rear) 0 Wh 71.0 Wh 0% pending-charge
DisplayDevice (icon) 23.5 Wh 96.1 Wh 24% discharging

omarchy-battery-status prints Battery 94% · 3h 42m left · 7.1W / 25Wh — BAT0. The icon fill is ~24% because BAT1 is in the denominator at 0 Wh. Earlier the same session BAT1 was ~64% / 45 Wh, so the unused pack can drop to a 0 Wh report without a real dump.

The popup also pulls cycle_count and charge thresholds with BAT*/... | head -1, so those are BAT0 as well.

So it is not "only BAT0" everywhere: the icon is combined, the panel is BAT0. They disagree on a dual-battery ThinkPad, and BAT1 never appears as its own row.

Filed by Grok 4.6 via Grok Build.

unleashed-nick avatar Aug 16 '26 20:08 unleashed-nick

Same head -n 1 BAT0 path on a T460s, with an extra twist: BAT0 is present but electrically dead (0 V / 0 Wh), so DisplayDevice is also wrong (~49% / 10h to full while the live slice is at 99%). Filed #7916 / #7917 to drop dead packs rather than summing every present BAT*.

hilather avatar Aug 23 '26 15:08 hilather

Hi there, T480 user here, i fixed this by installing this plugin: https://omarchyplugins.com/plugin.html?id=cinco.batteries

~ 30 seconds fix in terminal: omarchy plugin add https://github.com/cinco/omarchy-batteries.git --enable omarchy restart shell

done :}

Image

m4729316-commits avatar Aug 28 '26 20:08 m4729316-commits

Open PR #8864 addresses the expanded-panel half of this report. The panel command currently selects the first BAT device even when the bar already has an aggregate reading; the PR switches the command to UPower aggregate status and multi-battery wattage.

rookepoole avatar Sep 01 '26 09:09 rookepoole

Checked against quattro at 902fd8ae: the mismatch is still there, and the cause is in the source. The bar icon, the optional bar percentage and the panel's progress fill all read UPower's combined DisplayDevice (shell/plugins/panels/power/Panel.qml:50 and :80). The panel's numbers — percentage, size, rate and time — come from omarchy-battery-status --shell, which takes the first BAT device upower -e lists (bin/omarchy-battery-status:21). On a T480 that is BAT0, so the panel shows BAT0's 94% next to a fill bar and icon showing the combined 24%. Cycles and the charge-threshold fallbacks also take the first BAT* match (:68-69, :110). Nothing on quattro has changed this yet.

Open pull request #10392 fixes the disagreement and already closes this issue: with more than one pack it reads DisplayDevice for the panel's numbers too, so the icon and the panel agree. It does not list BAT1 as its own row; per-battery rows are what #8904 and #7186 propose, and those are new features, not fixes. Two things it leaves alone: cycles and thresholds still come from the first pack, and a pack that is dead but still reports a full capacity still counts in DisplayDevice's total, which is #7916.

Nothing was run for this issue. It is a dual-battery machine that a worker cannot reproduce, and #10392 is reviewed and tested on its own. The diagnosis was checked by a second model, Codex at medium effort. It agreed, so its agreement is not independent proof, and it added that the panel's fill bar and its percentage text disagree with each other, which is confirmed above.

This waits on the maintainer's decision on #10392.

omarchybot avatar Oct 08 '26 04:10 omarchybot

Still reproduces on Omarchy 4.0.6-1 (ThinkPad T480, both packs healthy). BAT0 is idle at 99%, BAT1 is discharging. The bar shows DisplayDevice's 76%, but the panel shows BAT0: 99% / fully-charged / 0W / 16Wh, with an empty time field. The threshold shows 96-80% (#7374), although sysfs end is 100.

Pointing the panel at DisplayDevice and summing power_now across BAT* fixes it locally (76% / discharging / 8.9W / 89Wh / 7h 54m), so +1 for #10392.

L0thlorien avatar Oct 25 '26 13:10 L0thlorien

Adding a dual-battery datapoint that behaves differently from the ThinkPads above, in case it helps validate the parsing logic in #8864 / #14861.

Microsoft Surface Book 2 (18 Wh clipboard pack BAT1 + 57.3 Wh base pack BAT2, both SMP), Omarchy 4.0.6-1, UPower 1.91.5, kernel 7.2.8-9 (linux-omarchy).

Repro on 4.0.6-1: the bar icon/percentage read UPower's DisplayDevice (86%, ~9.8 W, ~5.7 h), while the power panel shows only BAT1:

$ omarchy-battery-status
Battery 86%  ·  4h 17m left  ·  4.1W / 18Wh      ← BAT1 only

$ upower -i /org/freedesktop/UPower/devices/DisplayDevice | grep -E "energy|percentage|time"
    energy:              55.74 Wh
    energy-full:         64.27 Wh
    energy-rate:         9.818 W
    time to empty:       5.7 hours
    percentage:          86.7279%

So Battery size 18Wh, Charge cycles 71, Time left 4h 17m and the 4.3 W draw are all BAT1-only, while BAT2 (energy-full 46 Wh, 127 cycles) is invisible to the panel.

One Surface-specific note: unlike the T460s/T480s reports, the Surface firmware keeps both packs discharging simultaneously instead of interleaving them, so power_now is non-zero on both BAT* (e.g. 4.1 W + 8.1 W) and summing sysfs works too — but the UPower DisplayDevice already provides the aggregate, so that matches the approach in #14861 (with the single-battery regression flagged in its review).

I verified locally with a small helper that aggregates all BAT* (sum energy_full / energy_now / power_now, cycles listed per pack) and the panel then reads 84% · 4h 15m · 12.6W / 64Wh · cycles 71 / 127, which matches the DisplayDevice. Happy to test the merged fix.

ichbinzephyr avatar Oct 25 '26 15:10 ichbinzephyr

Still reproduces on Omarchy 4.5.0-3 (ThinkPad T480 20L6S6QA00, kernel 7.2.15-1-omarchy, both packs healthy).

BAT0 (internal, 16 Wh) is idle at 100%, BAT1 (rear, 74 Wh) is discharging at 26%. The bar shows DisplayDevice's 39%, but the panel shows BAT0: 100% / fully-charged / 0W / 16Wh with no time left.

BAT0: Not charging, 100%, energy_full 16.3 Wh
BAT1: Discharging, 26%, energy_full 74.3 Wh, power_now 7.0 W
DisplayDevice: 39.6%, discharging, 35.87/90.57 Wh, 7.3 W, 4.9 h to empty

$ omarchy-battery-status --shell
percentage  100%
state       fully-charged
rate        0W
size        16Wh
time

Local workaround confirming the approach in the earlier comments: a cloned omarchy.power panel whose script reads percentage, energy and state from UPower's DisplayDevice, sums power_now across all BAT* for the live draw, and computes time left from the combined energy. The panel now shows 39% · 7.8W · 91Wh · 4h 35m, matching the bar. I also added a per-battery line (Internal battery 100% · idle · 16Wh / Removable battery 26% · in use · 74Wh), which helps on these machines because the firmware drains one pack at a time.

ljesus avatar Nov 10 '26 22:11 ljesus

Also reproduces on Omarchy 4.5.0-3, ThinkPad T480 (20L6SG7K00), kernel 7.2.15-1-omarchy, UPower 1.91.5.

This time the internal pack is the nearly empty one, so the panel looks worse than the bar:

AC online
BAT0: pending-charge, 6%, 1.22 / 20.39 Wh, 0 W
BAT1: discharging, 51%, 10.81 / 21.02 Wh, ~14 W
DisplayDevice: discharging, 29%, 12.05 / 41.41 Wh, 51 min to empty

$ omarchy-battery-status --shell
percentage  6%
state       holding
rate        0W
size        20Wh
time
cycles      252
threshold   75-80%

The panel says 6% and "holding at 75-80%" while the bar glyph shows ~29%. BAT0's pending-charge gets reported as a threshold hold even though it is far below the 75% start threshold (same as #7916), and BAT1's discharge isn't shown at all.

frogec avatar Nov 14 '26 15:11 frogec

Still reproduces on Omarchy 4.5.0-3, ThinkPad T480 (20L6SDU000), kernel 7.2.15-1-omarchy, UPower 1.91.5.

This time the internal pack is not dead but heavily degraded, which makes the panel's numbers look plausible at a glance while the bar and the notification disagree with them:

BAT0 (internal, SMP 01AV421, Li-poly):  discharging, 1.52 / 5.05 Wh  (design 24 Wh → 21.0% capacity), 422 cycles
BAT1 (rear Power Bridge, LGC 01AV492):  pending-charge, 3.56 / 64.97 Wh (design 71.1 Wh → 91.4% capacity), 132 cycles
DisplayDevice: discharging, 5.08 / 70.02 Wh, 7.021 W, 43.4 min to empty, 7.26%
$ omarchy-battery-status --shell
percentage  30%
state       discharging
rate        7W
size        5Wh
time        13m
cycles      422

So the panel shows 30% / 5Wh / 422 cycles — that is BAT0 alone, the 24 Wh internal pack that can no longer hold more than 5 Wh. The bar's fill and the low-battery notification both read the composite DisplayDevice and show ~7-8% of the real 70 Wh. Two readings of "how much battery do I have" in one window, one of them off by 4x.

A detail that makes the panel actively misleading here: because the internal pack lost 79% of its capacity, "30%" of 5 Wh is about 1.5 Wh, i.e. ~2% of what the machine shipped with. A user reading the panel would believe there is a third of a charge left while the machine is about to die.

It also gets the time wrong in the same direction: 13m from BAT0's 1.52 Wh against BAT0's own rate, versus 43m for the 5.08 Wh the machine actually has.

For reference, the numbers that agree with each other are the ones from the composite device:

$ upower -i /org/freedesktop/UPower/devices/DisplayDevice
    energy:              5.08 Wh
    energy-full:         70.02 Wh
    energy-rate:         7.021 W
    time to empty:       43.4 minutes
    percentage:          7.25507%

Hardware notes, in case they help with the fix: the two packs are not interchangeable, and the internal one is the only 24 Wh pack with FRU 01AV421 (the 24 Wh Power Bridge option is a different FRU), so BAT0 is always the internal 24 Wh cell and BAT1 the external 72 Wh one here. The panel would also benefit from a per-battery breakdown, since "which pack is this?" is the first question on a dual-battery ThinkPad.

josperdom1 avatar Nov 21 '26 20:11 josperdom1