Skip to content

UpowerBackend: use DisplayDevice for ac adapter status when avail

Méven Car requested to merge meven/powerdevil:bug-fix-onbattery into master

Sometimes powerdevil applet will report the ac adapter to not be plugged in despite it is.

This is due to UPower OnBattery property being unreliable.

Switching to using DisplayDevice instead solves the issue.

For instance with my ac adapter disconnected:

CCBUG 423556 CCBUG 440609

19:41 $ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              mar. 19 oct. 2021 19:41:34 (11 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SMP
  model:                DELL G8VCF6C
  serial:               2166
  power supply:         yes
  updated:              mar. 19 oct. 2021 19:41:34 (11 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              23,6056 Wh
    energy-empty:        0 Wh
    energy-full:         28,7812 Wh
    energy-full-design:  51,9992 Wh
    energy-rate:         11,7952 W
    voltage:             8,561 V
    time to empty:       2,0 hours
    percentage:          82%
    capacity:            55,3493%
    technology:          lithium-polymer
    icon-name:          'battery-full-symbolic'
  History (charge):
    1634665294  82,000  discharging
    1634665213  81,000  discharging
  History (rate):
    1634665219  11,795  charging
    1634665216  10,891  discharging

Device: /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o001
  native-path:          ucsi-source-psy-USBC000:001
  power supply:         yes
  updated:              mar. 19 oct. 2021 09:20:16 (37289 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o002
  native-path:          ucsi-source-psy-USBC000:002
  power supply:         yes
  updated:              mar. 19 oct. 2021 09:36:30 (36315 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o003
  native-path:          ucsi-source-psy-USBC000:003
  power supply:         yes
  updated:              mar. 19 oct. 2021 14:58:08 (17017 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              mar. 19 oct. 2021 19:41:34 (11 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              23,6056 Wh
    energy-full:         28,7812 Wh
    energy-rate:         11,7952 W
    time to empty:       2,0 hours
    percentage:          82%
    icon-name:          'battery-full-symbolic'

Daemon:
  daemon-version:  0.99.11
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: PowerOff

This seems semi-related to https://gitlab.freedesktop.org/upower/upower/-/issues/22.

Edited by Méven Car

Merge request reports