[Bug 1973359] Re: on_ac_power says false, but real answer is true

Max Gaukler 1973359 at bugs.launchpad.net
Mon May 22 19:47:10 UTC 2023


*** This bug is a duplicate of bug 1980991 ***
    https://bugs.launchpad.net/bugs/1980991

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.

** This bug has been marked a duplicate of bug 1980991
   /usr/sbin/on_ac_power incorrectly reporting ac power status

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

Title:
  on_ac_power says false, but real answer is true

Status in powermgmt-base package in Ubuntu:
  Confirmed

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)

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




More information about the foundations-bugs mailing list