Public bug reported:
On my MacBookPro16,1 running on battery, on_ac_power exits 0 ("on AC
power") instead of 1 ("not on AC power"). systemd-ac-power gets it right:
$ grep . /sys/class/power_supply/*/{type,online,status}
/sys/class/power_supply/macsmc-ac/type:Mains
/sys/class/power_supply/macsmc-battery/type:Battery
/sys/class/power_supply/macsmc-ac/online:0
/sys/class/power_supply/macsmc-battery/status:Discharging
$ on_ac_power; echo $?
0
$ systemd-ac-power -v
no
Since LP: #1980991, on_ac_power only counts a battery whose name matches
BAT[0-9]+:
if echo "$FN" | grep -qE '/BAT[0-9]+$' && [ "$type" = "Battery" ];
then
This machine's battery is macsmc-battery (t2linux kernel 7.3.1), so
on_ac_power decides there is no battery and exits 0, although macsmc-ac
is offline. Ubuntu's generic kernel has batteries like that too: it
builds the axp288_fuel_gauge, max170xx_battery and chtdc_ti_battery
drivers (Cherry Trail tablets), and ACPI batteries are named by the
firmware. Debian's on_ac_power 1.39 has no such check and exits 1 here.
unattended-upgrades relies on on_ac_power to stop when the machine goes
on battery, so on such machines it won't.
Ubuntu 26.04.1, powermgmt-base 1.38ubuntu2. The check is in every
supported release (jammy to tenacious).
ProblemType: Bug
DistroRelease: Ubuntu 26.04
Package: powermgmt-base 1.38ubuntu2
Uname: Linux 7.3.1-2-t2-resolute x86_64
ApportVersion: 2.34.1-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: ubuntu:GNOME
Date: Sun Nov 1 16:29:44 2026
Dependencies:
PackageArchitecture: all
ProcEnviron:
LANG=sv_SE.UTF-8
PATH=(custom, no user)
SHELL=/usr/bin/fish
TERM=xterm-ghostty
XDG_RUNTIME_DIR=<set>
SourcePackage: powermgmt-base
UpgradeStatus: No upgrade log present (probably fresh install)
** Affects: powermgmt-base (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug resolute wayland-session
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2172719
Title:
on_ac_power says "on AC power" on battery if the battery isn't named
BAT<n>
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/powermgmt-base/+bug/2172719/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs