Dbus connection from service application

Hi everyone,
I am new at c++ programming and I have some problem with Dbus.
My application is a media player, I am using a raspberry 3 with Jessie.
I am trying to connect my application to the Omxplayer (raspberry player) Dbus.
It works if the application is run from a logged console, but if I create a service that launch the application I receive the following error:

dbus_bus_get_private(): /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

This is the code that I am using:

1
2
3
4
5
6
7
8
system("export DISPLAY=:0");
system("export $(dbus-launch)");

dbus_error_init(&error);
if (!(conn = dbus_bus_get_private(DBUS_BUS_SESSION, &error))){
  logger.warn("dbus_bus_get_private(): %s", error.message);
  goto fail;
}


Someone have any idea how to make it work as service too?
Thanks.

Last edited on
Topic archived. No new replies allowed.