0

I cannot figure out how to autostart a GUI application as the logged in user on the current Raspberry OS Full (Bookworm, 64-bit). I tried via systemd, but for some reason it fails, the error is as if the desktop environment is not fully initialized yet.

[Unit]
Description=My Autorun Service
After=graphical-session.target

[Service]
ExecStart=/home/pi/start_my_app.sh
WorkingDirectory=/home/pi/
Restart=always
RestartSec=2s
User=pi

[Install]
WantedBy=default.target

What are other possible way? Any better ways? Or is there anything wrong with my .service file?

7
  • for some reason what reason, the error is what exactly? not your interpretation, what is the error? Commented Dec 17, 2023 at 3:00
  • Trying to start ANY program which interacts with users at boot is an exercise in futility (as any of the hundreds of similar questions indicate). Commented Dec 17, 2023 at 3:09
  • @Milliways: I am under impression that graphical-session.target should work, according to all descriptions, it's made just for this. And yet it doesn't work. Commented Dec 17, 2023 at 9:40
  • Unfortunately you are mistaken. Whatever is in the service won't start until the target is satisfied BUT root can't do any I/O to the user. This can only happen AFTER login. There are autostart tools to do this but Bookworm uses new tools. Commented Dec 17, 2023 at 10:13
  • 1
    Have a look here: raspberrypi.com/tutorials/… Scroll down to the first occurance of the word "wayfire" and start reading a paragraph before that, it should be very simple. If that works out, please consider leaving an answer of your own, most of the ones here are out-of-date. BTW, adding "User=pi" does not automatically mean the service is part of that user's login; for that you must invoke systemctl --user enable as user Pi. Commented Dec 17, 2023 at 15:10

1 Answer 1

1

For Debian 12.4 Bookworm on RPi4 only the "Traditional" methods of this link How to Use Autostart for Desktop worked for me.

I created a .desktop file and it executed in both /etc/xdg/autostart, and alternately, a created /home/pi/.config/autostart/ directories.

1
  • I did it as suggested in the comments - via .config/wayfire.ini, this also works as expected. Commented Dec 26, 2023 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.