Help, I have been hit by the DBus and can't get up...

Jerry LeVan jerry.levan at gmail.com
Wed Jul 5 08:04:36 PDT 2006


Jerry LeVan wrote:
> Hi, I am trying to figure out how the Dbus works in Fedora Core 5.
>
> I suppose I need to use the python bindings but nice examples seem to
> be hard to find...
>
> One thing I would like to do is to be able to talk to Hal and gnome
> power manager,
>
> For example I have found via googling the following two examples
> using dbus-send:
>
> Ex 1:
> dbus-send --system --print-reply --reply-timeout=2147483648 \
> --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer \
> org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
>
> Ex 2:
> dbus-send --session \
> --dest=org.gnome.PowerManager \
> --type=method_call \
> /org/gnome/PowerManager \
> org.gnome.PowerManager.Suspend
>
> Both of the above work... the second one fails if I replace
> Suspend by Hibernate,
>
> How can use the introspection ability to find out "info" about
> the gnome power manager and hal?
> More generally how can I find out methods and signals of an
> arbitrary service?
>
> Thanks
>
> Jerry
>
>
Well I spoke too soon,,, Example 2 does work if Suspend is replaced by 
Hibernate (Must
have misspelled it earlier...)
The following
#!/usr/bin/env python
import dbus

bus = dbus.SessionBus()
remote_object = 
bus.get_object('org.gnome.PowerManager',"/org/gnome/PowerManager")

print remote_object.Introspect(
      dbus_interface="org.freedesktop.DBus.Introspectable")

Does give me the following
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 
1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg name="data" direction="out" type="s"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg name="interface" direction="in" type="s"/>
      <arg name="propname" direction="in" type="s"/>
      <arg name="value" direction="out" type="v"/>
    </method>
    <method name="Set">
      <arg name="interface" direction="in" type="s"/>
      <arg name="propname" direction="in" type="s"/>
      <arg name="value" direction="in" type="v"/>
    </method>
  </interface>
  <interface name="org.gnome.PowerManager">
    <method name="setDpmsMode">
      <arg name="mode" type="s" direction="in"/>
    </method>
    <method name="getDpmsMode">
      <arg name="mode" type="s" direction="out"/>
    </method>
    <method name="Shutdown">
    </method>
    <method name="Suspend">
    </method>
    <method name="Hibernate">
    </method>
    <method name="CanHibernate">
      <arg name="can" type="b" direction="out"/>
    </method>
    <method name="CanSuspend">
      <arg name="can" type="b" direction="out"/>
    </method>
    <method name="getOnAc">
      <arg name="on_ac" type="b" direction="out"/>
    </method>
    <signal name="DpmsModeChanged">
      <arg type="s"/>
    </signal>
    <signal name="OnAcChanged">
      <arg type="b"/>
    </signal>
  </interface>
</node>
Variations of the following prints nothing of value
#!/usr/bin/env python
import dbus

bus = dbus.SystemBus()
remote_object = bus.get_object('org.freedesktop.Hal',
    "/org/freedesktop/Hal/Device")

print remote_object.Introspect(
      dbus_interface="org.freedesktop.DBus.Introspectable")

How can I discover "Hal" methods....

Thanks,

Jerry





More information about the dbus mailing list