Ubuntu: $XAUTHORITY in systemd


I would like to know if there's a way to use $XAUTHORITY variable in systemd, basically, I have tried to create a simlink between $XAUTHORITY location and ~/.Xauthority by placing it in a script and launching the script at start-up with systemd, but that doesn't work.

After further testing (with echo $XAUTHORITY > debug and echo $PATH > debug), it shows that $PATH (for instance) can be used with systemd and not $XAUTHORITY.

One of the service files used (to understand why it didn't work) is the following:

[Unit]  Description=Create .Xauthority file in home  Requires=display-manager.service  After=display-manager.service    [Service]  ExecStart=/bin/bash -c 'echo $XAUTHORITY > /home/john/debug'  

This ExecStart initially was ln -fs $XAUTHORITY /home/john/.Xauthority but since it didn't work I tried with echo $XAUTHORITY and $PATH

[Install]  WantedBy=multi-user.target  

I want it in multi-user.target as I would like that simlink to be created before the start of other services whose author put in that group and that make use of Xauthority, for instance with the line:

Environment="DISPLAY=:0" "XAUTHORITY=/home/%i/.Xauthority"  

(service file for Thinkpad Yoga scripts)


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »