how to be notified when an application with dbus service lauchs or quits?

cbx bnucbx at gmail.com
Sat Sep 12 05:45:40 PDT 2009


I got it!
I use the wrong object path, so i can't get the signal
the correct one is /org/freedesktop/DBus,as follows
proxy = sessionBus.get_object('org.freedesktop.DBus',
'/org/freedesktop/DBus')

Thank you!



_______________________________
quoted text:

Thanks.Maybe i don't totally get what you mean.
i tried the following code.When rhythmbox lauches or quits,nothing is
printed.
Code in python:

import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gobject
import glib

class Test:
        def __init__(self):
                DBusGMainLoop(set_as_default=True)
                sessionBus = dbus.SessionBus()

                proxy = sessionBus.get_object('org.freedesktop.DBus',
'/')#this object path is wrong
                self.interface = dbus.Interface(proxy,
'org.freedesktop.DBus')
                self.interface.connect_to_signal('NameOwnerChanged',
self.callback)

                gobject.MainLoop().run()

        def callback(self, s1, s2, s3):
                print s1, s2, s3

if __name__ == '__main__':
        Test()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20090912/34170239/attachment.html 


More information about the dbus mailing list