This is noted as Fix Released in Oracular.

This is INCORRECT.  This command is STILL BROKEN in Oracular.

This is the result of running it on one of my Intel NUCs (which, I can
assure you, is *always* on AC power, as it has no battery).

[ganuc]: sh -x /usr/sbin/on_ac_power 
+ set -e
+ OFF_LINE_P=no
+ USB_IS_SINK=no
+ USB_IS_SOURCE=no
+ power_type=Mains
+ [ -d /sys/class/typec/ ]
+ test -d /sys/class/typec/port0
+ test -r /sys/class/typec/port0/power_role
+ cat /sys/class/typec/port0/power_role
+ power_role=[sink]
+ echo [sink]
+ grep -q \[source\]
+ + echo [sink]
grep -q \[sink\]
+ USB_IS_SINK=yes
+ test -d /sys/class/typec/port1
+ test -r /sys/class/typec/port1/power_role
+ cat /sys/class/typec/port1/power_role
+ power_role=[sink]
+ + echo [sink]
grep -q \[source\]
+ + grep -qecho \[sink\] [sink]

+ USB_IS_SINK=yes
+ [ yes = yes ]
+ power_type=USB*
+ [ -d /sys/class/power_supply/ ]
+ test -d /sys/class/power_supply/ucsi-source-psy-USBC000:001
+ test -r /sys/class/power_supply/ucsi-source-psy-USBC000:001/type
+ cat /sys/class/power_supply/ucsi-source-psy-USBC000:001/type
+ type=USB
+ [ -r /sys/class/power_supply/ucsi-source-psy-USBC000:001/online ]
+ cat /sys/class/power_supply/ucsi-source-psy-USBC000:001/online
+ online=0
+ [ 0 = 1 ]
+ [ 0 = 0 ]
+ OFF_LINE_P=yes
+ test -d /sys/class/power_supply/ucsi-source-psy-USBC000:002
+ test -r /sys/class/power_supply/ucsi-source-psy-USBC000:002/type
+ cat /sys/class/power_supply/ucsi-source-psy-USBC000:002/type
+ type=USB
+ [ -r /sys/class/power_supply/ucsi-source-psy-USBC000:002/online ]
+ cat /sys/class/power_supply/ucsi-source-psy-USBC000:002/online
+ online=0
+ [ 0 = 1 ]
+ [ 0 = 0 ]
+ OFF_LINE_P=yes
+ [ yes = yes ]
+ exit 1


So the result is 1, meaning "not on mains power". Which is WRONG.
It seems that the /sys/class/power_supply directory no longer contains info on 
always-on AC power.

As I have noted (somewhere).  The systemd code gets it roght.

[ganuc]: systemd-ac-power 
[ganuc]: echo $?
0


Note that on_ac_power code *does* get the correct result on a laptop (where 
there is a battery to check).

But it gets the incorrect result when running on a system that only has
AC power.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1980991

Title:
  /usr/sbin/on_ac_power incorrectly reporting ac power status

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/powermgmt-base/+bug/1980991/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to