I am building custom dbus
service for my own demands and want it to start automatically when someone need it. For that purpose I've created .service
file like this
[D-Bus Service]
Name=com.mycompany.servicename
Exec=/home/myuser/Workspace/service-start
User=myuser
Here I just changed the actual name of service and executable but this is not the point. I've double checked real names - it matches exactly.
I've placed this file under name com.mycompany.servicename.service to /usr/share/dbus-1/services folder (I am using Ubuntu 11.10)
Executable file has x
permissions for everyone.
And here is the problem - when I am trying to start client that performs
bus = dbus.SessionBus()
bus.get_object('com.mycompany.servicename','/path/to/object')
I get dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.mycompany.servicename was not provided by any .service files
Object with path '/path/to/object'
is registered right after service start.
I just don't get why dbus
can't find my .service
file. Maybe I am missing something? Any ideas?
Edit
I've managed to get D-BUS automatically start my script. The section of .service
file should be named [D-BUS Service]
instead of [D-Bus service]
The standard buses have /etc/dbus-1/system. conf and /etc/dbus-1/session. conf as their respective configuration files. Configuration files are in a simple XML-based format called busconfig.
You can run dbus on any modern Unix, Windows, or macOS platform; but it's only the standard system management IPC on Linux.
It's called 'socket activation' and 'dbus activation' (see current systemd docs). If you want to start service manually - then do systemctl disable <service-name> to disable start on boot. To start a service manually: systemctl start <service-name> .
dbus-daemon is the D-Bus message bus daemon. See http://www.freedesktop.org/software/dbus/ for more information about the big picture. D-Bus is first a library that provides one-to-one communication between any two applications; dbus-daemon is an application that uses this library to implement a message bus daemon.
Here's a short summary of the comments...
Create the subdirectory dbus-1/services/
in one of the directories named in the XDG Base Directory Specification. Usually, ~/.local/share/dbus-1/services/
works just fine. Enter the new subdirectory, create a file called com.mycompany.servicename.service
and add the lines:
[D-BUS Service]
Name=com.mycompany.servicename
Exec=/home/myuser/Workspace/service-start
User=myuser
Please note that D-BUS in [D-BUS Service]
needs to be capitalized.
That's it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With