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]
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!