D-Bus: Difference between revisions

From Alpine Linux
(This is a short stub, but I've found these details to be a frequently source of confusion)
 
(Move bit from Pipewire)
Line 3: Line 3:
Some services (including Pipewire) rely on a D-Bus session instance. Other processes will only be able to communicate with these services if d-bus is running.
Some services (including Pipewire) rely on a D-Bus session instance. Other processes will only be able to communicate with these services if d-bus is running.


The easiest way to run d-bus effectively is to use <code>dbus-run-session</code>. E.g.: when using sway, run it using:
You can start a dbus session like this: <code>dbus-run-session -- sh</code>(replacing sh with your shell or a window manager), or, <code>export $(dbus-launch)</code>. This is distinct from running dbus system-wide: <code>rc-service dbus start</code>, which is a prerequisite to run a user dbus session.
 
dbus-run-session sway


D-Bus passes the environment variable <code>$DBUS_SESSION_BUS_ADDRESS</code> to its children. Running <code>dbus-launch</code> in a terminal means that other running process won't find this  D-Bus's socket.
D-Bus passes the environment variable <code>$DBUS_SESSION_BUS_ADDRESS</code> to its children. Running <code>dbus-launch</code> in a terminal means that other running process won't find this  D-Bus's socket.

Revision as of 21:35, 26 February 2023

D-Bus is a message bus system that provides a mechanism for inter-process communication.

Some services (including Pipewire) rely on a D-Bus session instance. Other processes will only be able to communicate with these services if d-bus is running.

You can start a dbus session like this: dbus-run-session -- sh(replacing sh with your shell or a window manager), or, export $(dbus-launch). This is distinct from running dbus system-wide: rc-service dbus start, which is a prerequisite to run a user dbus session.

D-Bus passes the environment variable $DBUS_SESSION_BUS_ADDRESS to its children. Running dbus-launch in a terminal means that other running process won't find this D-Bus's socket.

If $DBUS_SESSION_BUS_ADDRESS is undefined, many applications will attempt to use the standard path:

$XDG_RUNTIME_DIR/bus

Running D-Bus like so should work for many applications:

dbus-daemon --nofork --address unix:path=$XDG_RUNTIME_DIR/bus --session