How to auto start a desktop app?

Hello all,

I need to auto start a desktop app on RPi 4. I used Xojo 2022R3.2 to compile. It runs when manually clicking on it, but I cannot get it to auto start with systemd.

Description=Axcys GraphiX



I’m having trouble with this. The syslog says:
ec 15 18:29:19 axcys systemd[1]: Started Axcys GraphiX.
Dec 15 18:29:20 axcys GraphiX[662]: Unable to init server: Could not connect: Connection refused
Dec 15 18:29:20 axcys GraphiX[662]: cannot open display:
Dec 15 18:29:20 axcys systemd[1]: axcys-graphix.service: Main process exited, code=exited, status=1/FAILURE
Dec 15 18:29:20 axcys systemd[1]: axcys-graphix.service: Failed with result ‘exit-code’.

Can anyone give me a clue what is wrong/how to fix this? Or is there a better way?


I suggest stating which OS the Pi is running and the version. The method changes from one OS to another. I wonder if those 662 errors mean the app does not have proper privileges.

maybe you app start without having a display context for the UI?
desktop apps usually run after a user login.

1 Like

I have done it like this:

sudo gpasswd -a pi sudo

In principle, this makes any other user a system administrator.
However, this change will only take effect after the user has logged out and back in, provided that the user “pi” was not already in the user group “sudo”.
sudo nano /etc/xdg/autostart/display.desktop

[Desktop Entry]

Where then has the code in it to start the Xojo Desktop app.

I forgot to add that in my example then you probably need to chmod the .sh file.

I am using this:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

and then add line there:


change path to whatever suits your needs. Works when graphical OS starts.

1 Like

Thank you all!

Pawel Soltysinski’s solution was the easiest and has worked perfectly.

Thank you again!

And proves that you are also using LXDE as DE as him. Lubuntu maybe?

Or… I see: Raspberry Pi OS, Debian based, has a desktop environment, PIXEL, based on LXDE.

if you need to start i.e. your web app server application with port 80 (instead of 8080 etc.) just use:

@sudo /home/pi/Desktop/YourProgramFolder/YourProgram

…since using port 80 is prohibited for standard user.