DBus .service file missing

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

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]

回答1:

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!



转载请标明出处:DBus .service file missing
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!