Xauthority error on alternate boot when execute a sudo application


I want to execute an application as root user(sudo) on startup. I’m using Beaglebone black with debian jessie lxqt image. I have created a .desktop entry to autostart my app in /etc/xdg/autostart also enabled the autologin feature of lightdm. It works smoothly on the very first boot then on the second time it shows the login window and on the third time it works. It works on alternate boot.

My .xsessio-errors displays the invalid MIT-Magic key error on sometimes and X server connection refused error on other times.

Tried the exporting .Xauthority of debian user to root user. No change.


I did some reading on this subject a while back, and apparently it has to do with the login manager you’re using. I say apparently because I did not explore this problem further. As I was exploring this issue for another person, and I typically run CLI only on my own equipment.

I believe I had found the potential solution by googling something like “run LXDE application at login” But I do not remember 100% what I searched for.