Next: , Previous: , Up: Inspection of D-Bus services.   [Contents][Index]

2.2 Bus names.

There are several basic functions which inspect the buses for registered names. Internally they use the basic interface ‘org.freedesktop.DBus’, which is supported by all objects of a bus.

Function: dbus-list-activatable-names &optional bus

This function returns the D-Bus service names, which can be activated for bus. It must be either the keyword :system (the default) or the keyword :session. An activatable service is described in a service registration file. Under GNU/Linux, such files are located at /usr/share/dbus-1/system-services/ (for the :system bus) or /usr/share/dbus-1/services/. An activatable service is not necessarily registered at bus already.

The result is a list of strings, which is nil when there are no activatable service names at all. Example:

;; Check, whether the document viewer can be accessed via D-Bus.
(member "org.gnome.evince.Daemon"
        (dbus-list-activatable-names :session))
Function: dbus-list-names bus

This function returns all service names, which are registered at D-Bus bus. The result is a list of strings, which is nil when there are no registered service names at all. Well known names are strings like ‘org.freedesktop.DBus’. Names starting with ‘:’ are unique names for services.

bus must be either the keyword :system or the keyword :session.

Function: dbus-list-known-names bus

This function retrieves all registered services which correspond to a known name in bus. A service has a known name if it doesn’t start with ‘:’. The result is a list of strings, which is nil when there are no known names at all.

bus must be either the keyword :system or the keyword :session.

Function: dbus-list-queued-owners bus service

For a given service, registered at D-Bus bus under the name service, this function returns all queued unique names. The result is a list of strings, or nil when there are no queued names for service at all.

bus must be either the keyword :system or the keyword :session. service must be a known service name as string.

Function: dbus-get-name-owner bus service

For a given service, registered at D-Bus bus under the name service, this function returns the unique name of the name owner. The result is a string, or nil when there is no name owner of service.

bus must be either the keyword :system or the keyword :session. service must be a known service name as string.

Function: dbus-ping bus service &optional timeout

This function checks whether the service name service is registered at D-Bus bus. If service has not yet started, it is autostarted if possible. The result is either t or nil.

bus must be either the keyword :system or the keyword :session. service must be a string. timeout, a nonnegative integer, specifies the maximum number of milliseconds before dbus-ping must return. The default value is 25,000. Example:

(message
 "%s screensaver on board."
 (cond
  ((dbus-ping :session "org.gnome.ScreenSaver" 100) "Gnome")
  ((dbus-ping :session "org.freedesktop.ScreenSaver" 100) "KDE")
  (t "No")))

To check whether service is already running without autostarting it, you can instead write:

(member service (dbus-list-known-names bus))
Function: dbus-get-unique-name bus

This function returns the unique name, under which Emacs is registered at D-Bus bus, as a string.

bus must be either the keyword :system or the keyword :session.

Next: Knowing the details of D-Bus services., Previous: D-Bus version., Up: Inspection of D-Bus services.   [Contents][Index]