Can I use Xlib in service?

25 Views Asked by At

I am writing a C++ program that will run as a service in ubuntu. In it I need to use the Xlib library to manage the X session. But because I'm running the program as a systemd service, it doesn't have access to the X session.

I tried to get around this by assigning the variables $XAUTHORITY and $DISPLAY to my service's environment. But the thing is, there is no way I can get the $XAUTHORITY variable from the service. Since it contains the path to the X session authorization file, I tried to find the path myself by knowing the UID, but the authorization file is in different places in different systems.

Is there any other way to get around this limitation and access Xorg from the systemd service?

0

There are 0 best solutions below