Skip to main content
Version: 0.15.1

The host's buses

A Plugin that speaks to the host's services — NetworkManager, UPower, BlueZ, systemd — does it on D-Bus, and runs on the host to do it. A unit is started with nothing of the environment that started the Core: it is handed the variables that are Yoke's and those its declaration names, and no others. Two buses matter, and each is found without a variable.

BusWhere it isHow a unit with no variable finds it
the system's/run/dbus/system_bus_socketevery D-Bus library's default for the system bus — nothing to do
the account's/run/user/<uid>/bus, where systemd puts it for the account running the Corefrom the unit's own user id, since DBUS_SESSION_BUS_ADDRESS is not handed

The pool's services Plugin is the example to read: it reaches the system's manager on the system bus, and the account's own manager on the account's bus, built from its user id when the variable is absent.

/// The account's bus. A unit is launched with no environment beyond its own, so without
/// DBUS_SESSION_BUS_ADDRESS the bus is looked for where systemd puts it.
async fn session_bus() -> zbus::Result<zbus::Connection> {
if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_some() {
return zbus::Connection::session().await;
}
let uid = rustix::process::getuid().as_raw();
zbus::connection::Builder::address(format!("unix:path=/run/user/{uid}/bus").as_str())?
.build()
.await
}

A Plugin in a container reaches neither bus: no class of need carries one, and the answer to a need the set cannot name is the host. Declare the unit without an image.

What the bus allows is still the host's to decide. A grant lets a unit's Plugin declare and act on what it declares; polkit, and the service itself, decide what the account may do through the bus. A Plugin says what the host allowed — services.permissions, network.permissions — rather than finding out at the first refusal.

Before the desktop, and after​

An instance may be started before the graphical session exists: by the account's systemd at boot, or from a login on a console. The guardian that starts it keeps the environment it was started with, and every Core it starts has that environment, whatever a later session holds.

A unit needsFound when the instance began before the desktop
audioyes: PipeWire's and PulseAudio's sockets have default places under the runtime directory, and are found once they exist
display, on Waylandyes, where the compositor made one socket under the runtime directory: with no WAYLAND_DISPLAY, the one wayland-* socket there is the display, at every launch; with two compositors running, name the one in WAYLAND_DISPLAY
display, on X11no: DISPLAY and its authority have no default place, and only the environment names them
the account's busyes: its place does not depend on the session

The practice that leaves nothing to chance is to start the guardian after the graphical session, so that its environment holds what the session set — for a systemd user unit, ordered after graphical-session.target; a desktop shell that attaches to an application is started by the compositor anyway, beside it (an application).

A unit launched before its display existed fails that launch, its failure naming the need, and is launched again by its restart policy; it starts once the socket is there.