1

TL;DR I'm looking for a way to autostart graphical applications, without first requiring the user to manually login.
I'm improving my Vdesktop script that runs multiple versions of Raspbian on one Pi simultaneously using systemd-nspawn.

I am working towards building a GUI tool that manages SD cards and image files, as well as booting them.
The only hindrance to a GUI tool able to 'boot' a Raspbian image is the bothersome manual console login.
enter image description here I'm looking for a way to autostart graphical applications, without first requiring the user to manually login.
Either getting the console to autologin (I've tried, I failed), or finding an autostart method that can run lxsession in the foreground, with no need for console login first.

I'd like to stay away from having the script automatically type in 'pi', and 'raspberry', because Vdesktop must work properly on a system whose Pi password has been changed.

  • 1
    Why is lightdm.sevice not starting? Can you edit the lightdm configuration to connect to the Xephyr server? – Craig Dec 4 at 22:23
  • I doubt there is a silver bullet here. The two solutions I'm aware of (lightdm/agetty) are already mentioned, and I would try to understand why they don't work in nspawnd container rather than hoping to find yet another one. – Dmitry Grigoryev 2 days ago
  • I think it comes down to the container not having a /dev/tty0. Because when I run /usr/sbin/lightdm, it errors Error opening /dev/tty0: No such file or directory. Is there any way to fix this? – Botspot yesterday
1

There are probably a few ways to do this, but what I've done in the past is to first set up an auto-login service for the user account that would run the application:

sudo nano /etc/systemd/system/autologin@.service

[Service]
ExecStart=-/sbin/agetty --autologin app_user %I $TERM

Then in the user .profile, start an X session:

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

Lastly, in the user X init file (.xinitrc) start the GUI application:

exec python gui_app.py

This may not be the best way, but it worked for me on an application that only had a graphic display and didn't require (or have) any user input. Note that this setup does rely on systemd.

  • Yes, this works on a Pi. For some reason not on a systemd virtual machine. Raspbian already has autologin@.service by default. – Botspot Dec 3 at 15:20
  • @Botspot What is a systemd virtual machine? You do not use a Raspberry Pi that would be a systemd real machine? – Ingo Dec 3 at 20:20
  • @Ingo good question. I have developed a script that uses systemd-nspawn to 'boot' a raspbian virtual machine on a Raspberry Pi. A way to run several OS'es at once for testing, development, comparison, backups, compiling in a disposable OS, etc. – Botspot Dec 3 at 22:00
  • Vdesktop takes a Raspbian .img file, and boots it inside a VNC-style window. – Botspot Dec 3 at 22:02
  • 1
    @Botspot No problem, it was only for my understanding because you don't mention it in the question. I have only skimmed the thread you have linked, tl;dr. And sorry, I just don't have a desktop available on my RasPi. I'm one of the guys loving the command line on a black and white console ;-) – Ingo Dec 4 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.