No autostart to Desktop as user

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version 9.14
  • Distro version | Bookworm
  • Kernel version | 6.12.20
  • Architecture | arm64
  • SBC model | RPi4

I have a similiar issue like mentioned above. Tried everything what was mentioned there but I have no devce timeouts. And would also not start after a delay.
As my standard user I can autologin to console, and startx into mate. That works.
But autologin to Desktoop does not- I tried 16 and in diet-pi-autostart. Both only brings me to the ‘hit return to login’ prompt. It works fine with root.
I tried downgrading to version 1.26

I have now added startx to my .bashrc what kind of works but I’d like to know what’s going on.
I have no clue what to do anymore since it coorelates with problem no 2. I have a feeling that it has to do with the vnc server.
I am using TigerVNC to usually connect via vnc to the server since it’s remote. But that doesn’t work anmore if I have an active desktop running on my monitor. And vice versa, so the autologin maybe fails because the vncserver is already started. I can also not start a desktop if an active vnc desktop is running. The error message: “Could not acquire name on session bus”.
I tried the SHARE_DESKTOP=1 setting in Dietpi.txt but that didnt work either.

One point I just want to mention because I don’t know whether it’s important or not: I know that I run xhost + on startup. I forgot why exactly that was neccessary but I think it was because of vncserver not working without it.

Thanks for your report.

In both cases (auto and manual), login as non-root user is done via LightDM. Can you check its service logs:

journalctl -u lightdm

At the moment: no entries

Hmm, does that symlink exist and point to the LightDM service?

ls -l /etc/systemd/system/display-manager.service

And if so, is it “WantedBy” the graphical target as expected?

systemctl show -p WantedBy display-manager

No, the sysmlink does not exist.
and
❯ cat /etc/X11/default-display-manager
/usr/sbin/lightdm
❯ systemctl status display-manager.service
Unit display-manager.service could not be found.

systemctl show -p WantedBy display-manager
WantedBy=graphical.target

update: I have created the link and started the service.
It seems to work, got a login mask could login.
Then changed autostart to 16 and 2 again und that still didnt work.
After reboot
systemctl status display-manager.service
lightdm.service - Light Display Manager
Loaded: loaded (/lib/systemd/system/lightdm.service; enabled
; preset: enabled)
Active: inactive (dead)

Starting it manually still works though.

Please try again to select one of the two desktop options in dietpi-autostart. If you select a different user than root, the symlink is created, or you would see an error prompt.

It is essential for LightDM to start, there is no other (intended) mechanism. Even

systemctl enable lightdm

does nothing else than creating that symlink, just with a bunch of noisy hassle around (which is why we skip it).

You are right if I choose 2 or 16 the link will be created. It wasn’t because 2 and 16 are not working and I switched to 7. Autologin to console works and hence I chose to add

if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = 1 ]; then
    exec startx
fi

to my .bashrc.
This actually works.
Everything else still doesn’t. If I go to 2 or 16 there won’t be a login.

Is there anything else you could say to fix this?

And how can I fix that I can use vncserver again?

What happens if you start the LightDM service manually?

systemctl start lightdm

And then check its logs:

journalctl -u lightdm

To avoid misinterpretation, I am on autostart setting 7 right now because that is the only way I get it running. Problems occur with 2.
If I do what you said:

systemctl start lightdm
starts the login mask and journalctl:
Jun 21 16:48:17 THALIN systemd[1]: Starting lightdm.service - Light Display Manager...
Jun 21 16:48:17 THALIN systemd[1]: Started lightdm.service - Light Display Manager.
Jun 21 16:48:19 THALIN lightdm[433633]: pam_unix(lightdm-greeter:session): session opened for user lightdm(uid=105) by (uid=0)

Okay, so the LightDM service generally works well, and the symlink is created. But despite that, the service does not seem to be started, even if the symlink exists?

Can you check the following:

systemctl show -p WantedBy display-manager
journalctl -u graphical.target

Ah, and maybe, since display-manager.service is invoked, not lightdm.service, we just checked for the wrong unit in the logs. So with autostart option 2 or 16, if LightDM does not show up:

journalctl -u display-manager -u lightdm  -u graphical.target
❯ systemctl show -p WantedBy display-manager
WantedBy=graphical. Target
❯ journalctl -u graphical.target
Jun 20 16:03:38 saruman systemd[1]: Stopped target graphical.target - Graphical Interface.
-- Boot 91ec47d2d6ad41ada3c10c98eec4e43d --
Jun 20 18:40:56 saruman systemd[1]: Reached target graphical.target - Graphical Interface.
Jun 20 19:41:21 saruman systemd[1]: Stopped target graphical.target - Graphical Interface.
❯ journalctl -u display-manager -u lightdm  -u graphical.target
-- Boot 6b027605f5a940e88a106d2758a1c5fb --
Jun 20 19:43:14 saruman systemd[1]: Starting lightdm.service - Light Display Manager...
Jun 20 19:43:14 saruman systemd[1]: Started lightdm.service - Light Display Manager.
Jun 20 19:43:15 saruman lightdm[1565]: pam_unix(lightdm-autologin:session): session opened for user sour(uid=1000) by (uid=0)
Jun 20 19:43:17 saruman systemd[1]: Reached target graphical.target - Graphical Interface.
Jun 20 22:51:23 saruman systemd[1]: Stopped target graphical.target - Graphical Interface.
Jun 20 22:51:23 saruman systemd[1]: Stopping lightdm.service - Light Display Manager...
Jun 20 22:51:24 saruman systemd[1]: lightdm.service: Deactivated successfully.
Jun 20 22:51:24 saruman systemd[1]: Stopped lightdm.service - Light Display Manager.
Jun 20 22:51:24 saruman systemd[1]: lightdm.service: Consumed 2min 16.286s CPU time.

I need to know how I can access the running desktop via vnc. Do I need to use something else than TigerVNC?

I will try realvnc.

So this time it worked well, doesn’t it? LightDM was starting as expected, no error etc, should show up on an attached screen.

Either of both should work the same way. To connect to the already running local X session:

G_CONFIG_INJECT 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=' 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=1' /boot/dietpi.txt
systemctl restart vncserver

Without this, it will create a new virtual X session for the VNC server only, suitable for headless/server/remote systems.

Ok I managed to get Realvnc running, so that’s out of he way.
Regarding the LightDM. I don’t know what you are refering to. I think you always think that I am on one of th eautostart options 2 or 16 but I am - and that’s why I said this: “To avoid misinterpretation, I am on autostart setting 7”. Nothing is working unless I do it myself aka exec startx.

This option 7 is the option to login to command line, it is not supposed to start a desktop. Of course there you need to run startx manually.

Joulinar thank you for jumping in, but please read the whole thread and understand the problem before trying to lecture me.

Let me know if you want to try fixing the autostart options 2 or 16 for you, since this is what I intended to. You did show output of LightDM service logs, showing that it started, so I assume, to get these logs, you did enable option 2 or 16, and hence I was asking whether, in this case you had a LightDM login prompt or desktop on your locally attached screen.