I looked into this, this, this and this and couldn't find an answer. I'm trying to implement Example 5 from systemd.service but it's not working. Of course the reason is that I didn't quite understand how dbus activation works. In my mind, once a DBus name starts being used, a service would be activated and my program would run. Am I too far off?

So, to test, I wanted that when I run my python3 program which "uses" a dbus name, my service would be started.

Anyways, can anyone direct me to the right place? My files:

# cat /etc/systemd/system/mydbus.service
Description=Service Started by DBus name

ExecStart=/bin/echo started
# ExecStart=/usr/bin/dbus-launch /usr/bin/python3 /home/myuser/Documents/dbus/client04.py
# the idea is that my python client up here will run once the server starts "consuming" the dbus name


Below is my dbus service (I think):

# cat /usr/share/dbus-1/system-services/org.mybus.demo.test.service 
[D-BUS Service]
Exec=/bin/echo started >> /home/myuser/Documents/dbus/org.mybus.demo.test

Now I run $ sudo journalctl -exfu mydbus. On another terminal, I start my server04.py:

# cat /home/myuser/Documents/dbus/server04.py 
# Importing
from pydbus import SessionBus
from gi.repository import GLib
import time

# Variables / Constants / Instantiation...
bus = SessionBus()
BUS = "org.mybus.demo.test"
loop = GLib.MainLoop()
message_count = 0

class DBusService_XML():
    DBus Service XML Definition.
    type = "i" for integer, "s" for string, "d" for double, "as" list of string data.
    dbus = """
        <interface name="{}">
            <method name='greeting'>
                <arg type="s" name="input" direction="in">
                <arg type="s" name="output" direction="out">

    def greeting(self, clientName):
        "Receive and send arg"
        print("{} is asking for name".format(clientName))
        return "Hello {}, Im Kyle".format(clientName)

if __name__ == "__main__":
    bus.publish(BUS, DBusService_XML())

I though that by doing that, my mydbus.service would start and I would see "started" in journalctl, but nothing happened. So, how do I do that?

PS.: of course that when I run my server04.py and client04.py manually with python, everything works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.