Debian iTOps Tube

Wednesday, May 16, 2012

How to have my program react to a DBus signal?

I'm endeavouring to use dbus to react to a particular signal (user clicks on an appindicator menu on the unity top panel). From using dbus-monitor, I've found the relevant signal that I'd like to react to:

sender=:1.96 -> dest=:1.232 serial=2091 path=/org/ayatana/NotificationItem/myapp/Menu; interface=com.canonical.dbusmenu; member=AboutToShowGroup
array [
int32 9

Then my plan was to do the following with python:

dbus_proxy = bus.get_object ("BUS.NAME", "PATH")
interface = dbus.Interface (proxy, "INTERFACE")
interface.connect_to_signal ("SIGNAL", my_function)

def my_function:
# react

In order to understand dbus, I've been using the following two articles:
the dbus-python tutorial and
How to read dbus-monitor output?

However, I'm a bit confused as to what values I should be using for bus name, path, interface and signal in my code. I've tried poking around in qdbus in order to work out the correct values, but I can't seem to find what I'm looking for. I think I've been thrown off because get_object requires a "well-known" name, but all I've got is the numerical unique identifiers for sender, dest.

Any nudge in the right direction would be greatly appreciated.

No comments:

Post a Comment