User Tools

Site Tools


Network and communication


24.9.0 D-Bus

This introduction to the topic of D-Bus subsumes parts from different literature sources to provide initial answers to the questions “What is D-Bus” and “What can D-Bus achieve?

D-Bus or Desktop-Bus is a framework of Inter-Process-Communication (IPC) and part of the freedesktop project ( IPC allows processes to exchange data in the form of messages. These messages are sent and received on a message channel. This channel is called D-Bus. D-Bus offers at least two buses for communication between processes. One is the global system bus and another is the session bus, to which every desktop of a logged on user is automatically connected within his desktop session when one of his applications registers on the D-Bus bus.

After switching on a computer with a Linux operating system, programs are also started that connect to the system bus and register there. If a user has logged on to the desktop, other programs start and log on to the session bus. What all programs registered on the D-Bus have in common is that they either offer a specific message service or use offered message services. A program that can register on the system bus or on the session bus should be marked as dbus-compatible.

In Mint 18.3, clicking the network icon in the taskbar opens a small menu window where you can turn the LAN or WLAN on or off. After switching off, the service with the ID :1.21 - behind which the D-Bus service org.gnome.networkmanager_applet is located - sends the signal 'NewIcon'. The service org.gnome.freedesktop.Notifikations receives it and evaluates the signal. The first reaction is to change the network icon in the task bar. Then the service sends a message named'Notify' to the D-Bus. The content of the message is a message and is displayed in a window on the desktop:


Figure Message on the desktop

Now you will surely ask yourself

  • where the information from the last section comes from,
  • which further messages the above service can send and
  • if you can use services offered as gambas programmer on the D-Bus or if you can offer your own services on the D-Bus with d-bus-capable gambas programs?

1. Answer
The answer is simple: To monitor the data traffic on the system bus or on the session bus, you can use the console program'dbus-monitor' like the author among others.

You can use the following commands to read a list of applications registered on the system bus and the session bus from a console. The list contains the D-Bus names and the unique connection IDs assigned to them, which are always preceded by a colon. The program qdbus is used:

$ qdbus --session | grep -v ":"
$ qdbus --system | grep ":"

You can also use the gambas program 'DBusView' and get an overview of all programs currently registered on the D-Bus:


Figure Registered programs on the D-Bus

2. Answer
You must know that each program registered on the D-Bus provides a description of the service offered in an XML file. There are several ways to view the content of the XML file. If you already know the D-Bus name of the application - for example via the'DBusView' program - then you can call the'Introspect' method of the standard interface'org.freedesktop.DBus.Introspectable'. This call is called introspection. Since the introspection is of central importance when working with the services on the D-Bus, it is described in a separate chapter In order to inform yourself about all programs and their services on the system bus or on the session bus, the program'd-feet' is the first choice, the use of which is described in detail in chapter

3. Answer
Yes - the component gb.dbus provides you with several classes to use services on the D-Bus or to offer services or to intercept or send signals with your own d-bus-capable gambas programs.

The following chapters describe these classes with their properties, methods, and events. In addition, numerous projects are presented to you, which should give suggestions for your own d-bus-compatible programs.

Overview of the chapters

  • Chapter Gambas and DBus: D-Bus, D-Bus Message, D-Bus Name, D-Bus Address, D-Bus Object and D-Bus Interface are the focus.
  • Chapter D-Bus Introspection: The ability of a program to examine the properties of an exported D-Bus object at runtime is called introspection. With the component gb.dbus, Gambas has the ability to analyze and map in a suitable form a service, its objects, interfaces and their methods and properties as well as declared signals on the D-Bus. Many programs are presented with which specific aspects can be analyzed.
  • Chapter D-Bus Signature: You need signatures to map the D-Bus data with its D-Bus data types to Gambas data and its data types and vice versa. Two extensive examples with complex signatures show the necessary data conversion.
  • Chapter 24.9.1 Class DBusObject: The (static) class is the parent class for all objects that you can export to the D-Bus.
  • Chapter 24.9.2 Class DBus: The class DBus manages the connection of an application to the session bus or the system bus. You can use these methods to register a D-Bus object on the D-Bus, de-register it or check whether a d-bus-compatible application is registered on the D-Bus. You can send a D-Bus signal using the Raise(…) method. To check if a special D-Bus object of your Gambas application is already registered on the D-Bus, use the IsRegistered(..) method.
  • Chapter 24.9.3 Class DBusApplication: The class DBusApplication (gb.dbus) represents an application registered on the D-Bus and uses the class DBusConnection.
  • Chapter 24.9.4 Class DBusConnection: This class represents a connection of a d-bus-capable application to the System D-Bus or the Session D-Bus. It is primarily used to determine the applications registered on the System D-Bus.
  • Chapter 24.9.5 DBusObserver Class: In this chapter you will learn how to intercept a message on the D-Bus and display its contents. Two projects demonstrate the use of the class.
  • Chapter 24.9.6 DBusSignal Class: If you only want to intercept signals and display their contents, then this class provides a special observer. Three projects complement the theory.
  • Chapter 24.9.7 Class DBusProxy: This class shows how to define and use a D-Bus proxy.
  • Chapter 24.9.8 Class DBusVariant and DBusValues: With the help of both classes you can define methods and signals and thus offer services on the D-Bus and send signals with a Gambas program. The projects are always created as server-client projects.

The following list of links takes you to interesting websites, each of which deals in a special way with the topic of D-Bus:




The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k24/k24.9/start.txt · Last modified: 02.07.2018 (external edit)

Page Tools