Products › lamco-dbus-tools › Docs

Start a D-Bus service, set a property, take a name, send a signal

Start a D-Bus service, set a property, take its name and send a signal with dbusdo, each act recorded at the caller, and see what the bus saw in a recording.

Describes version 0.4.1. Run 2026-12-01 on Debian 13 against a private dbus-daemon 1.16.2 and a made-up service; docs/measurements/stage-13/drive/ has the script, the service and what it printed.

dbusdo changes things on a bus, each act recorded at the caller with --out. Every act here is layer 4 or 5: It starts a service or changes state, which dbussee never does. Run them against a bus and service you're testing, not one a desktop depends on.

The service for this page is lamp.py: com.example.Lamp at /com/example/Lamp, with a Brightness property, startable from a service file, and taking its name so that another connection may replace it.

Start a service, and time it

$ dbusdo --out acts.json start com.example.Lamp
com.example.Lamp started; its name had an owner 41.41 ms after the request

start asks the bus to start the name (StartServiceByName) and watches for its owner, so the figure, taken at the caller, is the whole start: The bus running the program, the program connecting and taking its name. A name with no service file fails at once with the bus's ServiceUnknown. A name already running answers already_running, and nothing is started.

Set a property, and read it back

$ dbusdo set com.example.Lamp /com/example/Lamp com.example.Lamp.Brightness u 7
$ dbusdo call com.example.Lamp /com/example/Lamp org.freedesktop.DBus.Properties.Get ss com.example.Lamp Brightness
[7]
answered in 157.92 µs at the caller

set is org.freedesktop.DBus.Properties.Set with the value typed as its signature says: u 7, s text, as 2 a b. It prints nothing when the service accepts it and exits 1 with the service's error when it doesn't.

Take a service's name

$ dbusdo own com.example.Lamp 1
own com.example.Lamp 1: com.example.Lamp wasn't taken: the bus answered exists
$ dbusdo own --replace com.example.Lamp 1

Without --replace a name someone owns isn't taken, and own exits 1. With it, the bus gives the name to dbusdo when the owner allowed replacement when it took it, as the lamp did, and the lamp is told with NameLost. dbusdo holds the name for the seconds given, then releases it. Callers of the name reach dbusdo meanwhile and get no answer: It's a way to see how a program behaves when its service stops answering.

Send a signal

$ dbusdo emit - /com/example/Lamp com.example.Lamp.Flicker u 3

- broadcasts it to whoever asked the bus for it; a unique name in its place sends it to that connection only.

What the bus saw

A recording beside the acts shows each one:

$ dbustell names rec.json
2 well-known names; 1 of them changed during the recording. 7 connections joined and 7 left.

NAME                      AT  OLD OWNER   NEW OWNER
com.example.Lamp      1.04 s  -           :1.3
com.example.Lamp      1.05 s  :1.3        :1.7
com.example.Lamp      2.05 s  :1.7        -

Changed hands: com.example.Lamp

Lost and not retaken by the end: com.example.Lamp
$ dbustell signals rec.json
38 signals in 6.0 s, 5 kinds by sender, member and path. A storm is 100 or more of one kind in one second.

SENDER                   SIGNAL                                               COUNT     PER S    PEAK  PATH
org.freedesktop.DBus     org.freedesktop.DBus.NameOwnerChanged                   17      2.83      13  /org/freedesktop/DBus
org.freedesktop.DBus     org.freedesktop.DBus.NameAcquired                        9      1.50       8  /org/freedesktop/DBus
org.freedesktop.DBus     org.freedesktop.DBus.NameLost                           10      1.67       6  /org/freedesktop/DBus
:1.3 (com.example.Lamp)  org.freedesktop.DBus.Properties.PropertiesChanged        1      0.17       1  /com/example/Lamp
:1.8                     com.example.Lamp.Flicker                                 1      0.17       1  /com/example/Lamp

The lamp took its name when started (:1.3), dbusdo own --replace took it (:1.7) and released it a second later, and the lamp, having lost it, exited. The set shows as the lamp's PropertiesChanged, and the broadcast as Flicker from dbusdo's connection.

In a chain

Each act is also a step of a chain: Commands one after another in one run, pause between them, soft before one that may fail without ending the chain, and retry before one to repeat (the chain). Run on a fresh bus (chain.sh):

$ dbusdo --out acts.json start com.example.Lamp set com.example.Lamp /com/example/Lamp com.example.Lamp.Brightness u 7 pause 1 soft own com.example.Lamp 1
com.example.Lamp started; its name had an owner 42.24 ms after the request
own com.example.Lamp 1: com.example.Lamp wasn't taken: the bus answered exists (allowed to fail)

It exits 0: The own failed, as the lamp still had its name, and was allowed to. acts.json holds a record of each act, start, set and own, with its outcome.