troubleshooting gnome-power-manager and gnome-power-preferences

by Martin Monperrus

On a Gnome desktop on Linux, [[http://projects.gnome.org/gnome-power-manager/|gnome-power-manager]] is responsible for handling battery events and physical events (laptop lid closed, power button pressed, etc). The tool ‘’gnome-power-preferences’’ configures it.

In recent versions, ’’gnome-power-*’’ is built on top of [[http://upower.freedesktop.org/|Upower]]. UPower publishes all hardware events on [[http://www.freedesktop.org/wiki/Software/dbus|DBUS]] (in previous versions, it was the job of HAL, which is no longer used in gnome-power-manager). It also receives user commands for instance to suspend the computer. UPower internally uses [[http://pm-utils.freedesktop.org/wiki/|pm-utils]]’ utilities (pm-is-supported, pm-suspend, pm-hibernate, see upower development file ‘’linux/up-backend.c’’). Also some events are filtered using [[http://www.freedesktop.org/wiki/Software/PolicyKit|PolicyKit]] rules.

If something goes wrong in the stack, many symptoms may appear (e.g. no option “suspend” and “hibernate” in gnome-power-preferences.)

=====Troubleshooting=====

Here are some hints for analyzing the gnome-power-manager stack.

Can you suspend directly from the kernel? ’‘$ echo mem > /sys/power/state’’ This command should suspend your system.

Can you suspend with pm-suspend as root? ’‘$ pm-suspend’’ This command should suspend your system.

Is upower installed? ’‘$ upower -d’’ This command should output a lot of information, including the related capabilities of the kernel (e.g. can-suspend), and the physical state (e.g. lid-is-closed)

Does upower publishes the information on dbus? ‘’qdbus –system org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.CanSuspend’’

Are you able to suspend by calling upower on DBUS? ’‘$ dbus-send –system –print-reply –dest=org.freedesktop.login1 /org/freedesktop/login1 “org.freedesktop.login1.Manager.Suspend” boolean:true’’

See also [[https://wiki.ubuntu.com/DebuggingGNOMEPowerManager]], [[http://upower.freedesktop.org/docs/UPower.html]] and numerous bug reports and forum posts on the web.

====Possible errors====
$ dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Error org.freedesktop.UPower.GeneralError: No kernel support

It seems that the value of the Gconf key “/apps/gnome-power-manager/general/can_suspend” is no more taken into account.

====Raw output====
$ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0003:00/power_supply/AC
  power supply:         yes
  updated:              Sat Mar 26 22:16:22 2011 (2723 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0
  vendor:               Samsung SDI
  model:                DELL RM66888
  serial:               10425
  power supply:         yes
  updated:              Sat Mar 26 23:01:27 2011 (18 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              27.4392 Wh
    energy-empty:        0 Wh
    energy-full:         71.5173 Wh
    energy-full-design:  86.58 Wh
    energy-rate:         16.5945 W
    voltage:             11.119 V
    time to empty:       1.7 hours
    percentage:          38.3672%
    capacity:            82.6026%
    technology:          lithium-ion
  History (charge):
    1301176887  38.367  discharging
    1301176856  38.585  discharging
    1301176825  38.802  discharging
    1301176794  39.019  discharging
  History (rate):
    1301176887  16.595  discharging
    1301176856  18.093  discharging
    1301176825  18.271  discharging
    1301176794  15.962  discharging

Daemon:
  daemon-version:  0.9.8
  can-suspend:     yes
  can-hibernate    yes
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no

$ dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.SuspendAllowed
method return sender=:1.14 -> dest=:1.110 reply_serial=2
   boolean true

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" --type=method_call --reply-timeout=6000 /org/freedesktop/UPower org.freedesktop.DBus.Properties.Get string:"" string:CanSuspend
false

$ cat /usr/share/polkit-1/actions/org.freedesktop.upower.policy 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>The UPower Project</vendor>
  <vendor_url>http://upower.freedesktop.org/</vendor_url>
  <icon_name>system-suspend</icon_name>

  <action id="org.freedesktop.upower.suspend">
    <description>Suspend the system</description>
    <description xml:lang="fr">Mettre le système en veille</description>
    <description xml:lang="it">Sospende il sistema</description>
    <description xml:lang="pl">Wstrzymanie systemu</description>
    <description xml:lang="sv">Försätt systemet i vänteläge</description>
    <message>Authentication is required to suspend the system</message>
    <message xml:lang="fr">Vous devez vous identifier pour mettre le système en veille</message>
    <message xml:lang="it">È richiesto autenticarsi per sospendere il sistema</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby wstrzymać system</message>
    <message xml:lang="sv">Autentisering krävs för att försätta systemet i vänteläge</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.upower.hibernate">
    <description>Hibernate the system</description>
    <description xml:lang="fr">Mettre le système en hibernation</description>
    <description xml:lang="it">Iberna il sistema</description>
    <description xml:lang="pl">Hibernacja systemu</description>
    <description xml:lang="sv">Försätt systemet i viloläge</description>
    <message>Authentication is required to hibernate the system</message>
    <message xml:lang="fr">Vous devez vous identifier pour mettre le système en hibernation</message>
    <message xml:lang="it">È richiesto autenticarsi per ibernare il sistema</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby zahibernować system</message>
    <message xml:lang="sv">Autentisering krävs för att försätta systemet i viloläge</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

</policyconfig>
Tagged as: