--- author: '' category: '' date: 2009/12/11 11:04 description: '' link: '' priority: '' slug: BB854 tags: open source, programming, pyqt, python, qt title: Making a unique application using python and DBUS type: text updated: 2009/12/11 11:04 url_type: '' --- No, not unique in the sense "oh, this app is a special snowflake", but unique in the sense "you can only run one copy of this application". I tried googling for it and I always found the same answer, "use dbus, try to own the name, if it exists already, then a copy is already running". What I could not find is one working example of this, or at least not something conveniently labeled "here is how you do a unique application using dbus and python". So, here is how you do a unique application using dbus and python: Supposing your application is called uRSSus (mine is): .. code-block:: python session_bus = dbus.SessionBus() try: session_bus.get_object("org.urssus.service", "/uRSSus") # This is the second copy, make the first one show instead # TODO: implement except dbus.DBusException: # No other copy running # This will 'take' the DBUS name name = dbus.service.BusName("org.urssus.service", bus=session_bus) # Now, start your app: window=MainWindow() object = UrssusServer(window,name) : : : etc, etc And that's it. No, it's not hard, but since the DBUS docs seem to be... rather they seem almost *not to be* sometimes, every little bit may help.