Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
This should typically be fairly easy, but it seems that DBus objects are created dynamically for their indicators. Reference Transmission with an indicator enabled in D-Feet to see. The real problem here is how to bus.get_object for your "myapp" bus name. –  Jacob Johan Edwards May 16 '12 at 5:24
Thanks for recommending d-feet. It's a highly useful tool for viewing available signals and methods. Through it, I realised 'AbouttoShowGroup' is actually a method, not a signal. This was something I over-looked in the dbus-monitor output. –  jwigley May 17 '12 at 1:52
add comment

1 Answer

up vote 0 down vote accepted

The add_signal_receiver function can be used without specifying a bus name. This can be useful for capturing signals when the bus name, interface or specific signal name is unknown.

session_bus = dbus.SessionBus()


The above code calls the do_something method every time a signal is received on the session bus.

In my original question, I stated I wanted to respond to 'AboutToShowGroup'. However, after closer inspection of the 'com.canonical.dbusmenu' interface, I realised it is in fact a method and not a signal. I have since chosen another signal to react to.

share|improve this answer
What signal did you use to determine that the user has clicked on your AppIndicator icon? –  Shah May 19 '12 at 14:01
I could not find any signals that seemed relevant for clicking on the AppIndicator icon. Instead, I re-thought my design approach and decided I wouldn't react to the menu being opened, but instead to other system events that would require my app to act. –  jwigley May 21 '12 at 3:09
Shah, while there is still no 'proper' solution for determining when a user has clicked on an AppIndicator icon. Sampo555 has come up with a workaround, reacting to the Unity Panel Service dbus. –  jwigley Sep 5 '12 at 23:24
Thanks, interesting read. I gave up on it as well and moved to a different approach, but if I revisit this area it will be a good point to start experimenting. –  Shah Sep 10 '12 at 22:34
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.