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 (https://www.freedesktop.org/wiki/). 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 184.108.40.206: Message on the desktop
Now you will surely ask yourself
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 ":" org.gnome.SessionManager org.gtk.Private.UDisks2VolumeMonitor ... org.PulseAudio1 org.freedesktop.DBus
$ qdbus --system | grep ":" ... :1.44 :1.5 :1.21
You can also use the gambas program 'DBusView' and get an overview of all programs currently registered on the D-Bus:
Figure 220.127.116.11: Registered programs on the D-Bus
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 18.104.22.168. 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 22.214.171.124.3.
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
The following list of links takes you to interesting websites, each of which deals in a special way with the topic of D-Bus: