Pi Launch App At session start

After seen this topic App autostart , and see that it doesn’t work with last version of my new Pi, I look the net and found solution.

For those who need to start their App at launch with Raspberry Pi, here is my method :

On the terminal : mkdir /home/<‘your home’>/bin

Copy the application inside

Now, on the terminal :
→ mkdir /home/<‘your home’>/.config/autostart
→ nano /home/<‘your home’>/.config/autostart/<‘your App Name’>.desktop (Like visualiseur.desktop)

insert the following content in the file <‘your App Name’>.desktop
[Desktop Entry]
Type=Application
Name=<‘your App Name’>
Exec=/home/<‘your home’>/bin/'<‘your App Name’>

Save the file using ‘Ctrl X’

reboot the Pi

1 Like

Hello @Valdemar_De_SOUSA ,

can you please specify the version of Pi OS this works with ?

This is something I hate about Linux: these kind of things change from version to version, what a nightmare :rage:. You carefully document how to install LAMP, when the next version is published, your old documentation is of no use because of the changes.

Thanks

1 Like

My Pi has this information :

Operating System: Debian GNU/Linux 12 (bookworm)
Kernel: Linux 6.6.31+rpt-rpi-v8
Architecture: arm64

If you’re running headless on debian 12 you can use this.


[Unit]
Description=X11 session for myapp
After=graphical.target systemd-user-sessions.service

[Service]
User=myapp
Group=myapp
WorkingDirectory=~

PAMName=login
Environment=XDG_SESSION_TYPE=x11
TTYPath=/dev/tty8
StandardInput=tty
UnsetEnvironment=TERM

UtmpIdentifier=tty8
UtmpMode=user

StandardOutput=journal
ExecStartPre=/usr/bin/chvt 8
ExecStart=/usr/bin/startx /opt/myapp/myapp -- vt8 -keeptty -verbose 3 -logfile /dev/null
ExecStop=/usr/bin/pkill myapp
Restart=always
RestartSec=3

[Install]
WantedBy=graphical.target