---
title: Notes - 3. DBus
date: 1970-01-01T00:00:00.000Z
slug: notes-dbus
---

### 3. D-Bus?

D-Bus is IPC system for Linux, it provides structualized way for apps to communicate with each other.

Desktop Bus System.

System-bus and session-bus

System services <-> root application / system users.

- Hardware events, system state managing, low-levels

User session <-> user applications and users.

- Desktop Environment, Apps.

=> Event-driven communication / Object-oriented

Messaging. - calls / returns / error / signal

Object - interface -> method -> property -> signal

Method = (call, return, error, signal)

D-Bus router = message broker / router (just like other message forward/proxy protocols)

Method Calls -> request of service? RPC?

Signals. kernel signal in userspace. send signal to application.

Objects .. Message = Serialized bytearray of any signal / method calls. It is like RPC. Multi-multi RPC-bus

D-Bus Message structure.

Byteorder / Message Type / Flags / Protocol Version / Length / UUID / Header / Body.

How and where can I use D-Bus in my application?

Communication with low-level D-Bus daemon(server).

Ex. MediaPlayer - Implement Play/Pause/Stop/Volume for user to control via DE's common interface i.e. play button on taskbar? Extensions? Anyway structulized way of control.

Ex. DE can get information about songs now playing, via D-Bus.

Ex. System monitoring application e.g. runCat.

Ex. Caffeine-ng -> prevents machine from sleeping.

Ex. Solaar -> Controls mouse/keyboard in low-level. Needs D-Bus.

How?

Define D-Bus interface via XML, signals. methods, props. (export to bus?) -> Implement by library -> Connect to D-Bus (sync with daemon?) -> Do something.

Session vs System D-Bus

Session ? e.g. Push notification to DE. we need to send it via d-bus.

System ? e.g. Power Event, kernel-level type of event managing.

