on_ac_power says false, but real answer is true

Bug #1973359 reported by Bjorn Toft Madsen
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
powermgmt-base (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

On a Dell 7000 Micro (Intel 12700T), plugged into mains power, on_ac_power reports false.

As the micro computer is plugged into mains power, I had expected it instead to report true.

/sys/class/power_supply$ ls
ucsi-source-psy-USBC000:001

/sys/class/power_supply/ucsi-source-psy-USBC000:001$ cat type
USB

/sys/class/power_supply/ucsi-source-psy-USBC000:001$ cat online
0

The initial logic in /usr/bin/on_ac_power goes:
if [ -d /sys/class/power_supply/ ]; then
    for FN in /sys/class/power_supply/*; do
        if test -d "${FN}" && test -r "${FN}/type"; then
            type="$(cat "${FN}/type")"
            case "${type}" in
            Mains|USB*|BrickID|Wireless)
                if [ -r "${FN}/online" ]; then
                    online="$(cat "${FN}/online")"
                    [ "$online" = 1 ] && exit 0
                    [ "$online" = 0 ] && OFF_LINE_P=yes
                fi;;
            esac
        fi
    done
    [ "${OFF_LINE_P}" = "yes" ] && exit 1
fi

Due the adapter being of type USB and the online status being 0, OFF_LINE_P is set to "yes" and the script exits with status code 1.

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: powermgmt-base 1.36
Uname: Linux 5.17.0-051700-generic x86_64
ApportVersion: 2.20.11-0ubuntu82
Architecture: amd64
Date: Fri May 13 11:50:59 2022
Dependencies:

InstallationDate: Installed on 2022-04-22 (21 days ago)
InstallationMedia: Ubuntu-Server 22.04 LTS "Jammy Jellyfish" - Release amd64 (20220421)
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: powermgmt-base
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Bjorn Toft Madsen (sunbeam60) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in powermgmt-base (Ubuntu):
status: New → Confirmed
Revision history for this message
Max Gaukler (mgmax) wrote :

Closing as duplicate of https://bugs.launchpad.net/ubuntu/+source/powermgmt-base/+bug/1980991 which is slightly newer but contains further discussion and even a suggested fix.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.