Search code examples
pythondbus

Xfce Python Dbus


I run Xfce (Arch Linux) and I'm trying to control the power manager. I already declared the power manager but what are the methods to hibernate it and control it? Here's my code so far:

from pydbus import SessionBus
bus = SessionBus
power = bus.get('org.xfce.PowerManager',           '/org/xfce/PowerManager')
power.hibernate

And it's not working. I've tried googling it, looking at docs, and guessing every method I could think of.


Solution

  • As Dartmouth mentioned, you need to find xfce4-power-manager's exposed methods. For that DFeet (a D-Bus debugger) will help you:

    enter image description here

    Then you can call the method (via terminal):

    dbus-send --session --print-reply \
    --dest=org.freedesktop.PowerManagement \
    /org/freedesktop/PowerManagement \
    org.freedesktop.PowerManagement.Hibernate