Signing into realvnc as non-root

I think you are mixing the two possible options. I just tested it on RPi 5 and these work well here, on a fresh DietPi Trixie system, after install RealVNC with LXDE:

  1. sudo systemctl stop vncserver
    # Assure shared desktop mode is used
    G_SUDO G_CONFIG_INJECT 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=' 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=1' /boot/dietpi.txt
    # Enable LightDM login
    dietpi-autostart 16
    # Alternatively use desktop autologin (2) with desired user
    dietpi-autostart
    sudo systemctl restart lightdm
    sudo systemctl start vncserver
    
    • Connect to 192.168.1.15:0 with TigerVNC viewer or RealVNC viewer, both work here
    • See LightDM on the VNC viewer or the desktop session with the selected user respectively. Note that LightDM is used in both cases, but in case of non-root autologin configured via /etc/lightdm/lightdm.conf.d/dietpi-autologin.conf to automatically login with the selected user. For the VNC server, it does not make any difference, it just connects to whichever existing X session. If no HDMI screen is attached, it uses a relatively low resolution 1024xsomething or so, which can be surely configured in X11 settings somewhere. I could not find a way to configure it in LXDE GUI. The monitor settings panel just says that no monitor is attached, hence resolution cannot be changed :sweat_smile:. Works well, of course, with a monitor attached. However, the other way with a virtual VNC session is better anyway, see option 2:
  2. Running the VNC server as non-root user for virtual sessions works actually pretty well. It does not require any additional permissions, systemd-logind and/or polkitd, and a /usr/bin/Xvnc -rootHelper helper process seem to manage everything. The needed steps as astro user:
    sudo systemctl stop vncserver
    # Disable desktop autostart and stop LightDM
    dietpi-autostart 0
    sudo systemctl stop lightdm
    # Create VncAuth password for virtual VNC sessions
    vncpasswd -virtual
    # Adjust `vncserver.service` to run as astro user
    sudo mkdir /etc/systemd/system/vncserver.service.d
    cat << '_EOF_' | sudo tee /etc/systemd/system/vncserver.service.d/astro.conf
    [Service]
    User=astro
    Environment=
    Environment=HOME=/home/astro
    _EOF_
    # Note: no typo with doubled Environment, the first is to clear the existing one, since those directives stack
    sudo systemctl daemon-reload
    # Assure that the service starts with a virtual session
    G_SUDO G_CONFIG_INJECT 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=' 'SOFTWARE_VNCSERVER_SHARE_DESKTOP=0' /boot/dietpi.txt
    # Restart service
    sudo systemctl start vncserver
    
    • Connect to 192.168.1.15:1
    • Note that for virtual sessions, the resolution selected via dietpi-config or dietpi-display do not matter, but it needs to be set via /boot/dietpi.txt:
      SOFTWARE_VNCSERVER_WIDTH=1280
      SOFTWARE_VNCSERVER_HEIGHT=720
      SOFTWARE_VNCSERVER_DEPTH=16
      

Generally, in both cases, I’d use KMS, i.e:

/boot/dietpi/func/dietpi-set_hardware rpi-opengl vc4-kms-v3d

On Trixie, when going with option 1, the autostart options enable KMS automatically, since LightDM requires it. Not sure whether RealVNC does so or not, but it should perform better as well. Resolution for local desktop sessions (only relevant for option 1) can btw not be controlled with dietpi-config or dietpi-display (the latter when using KMS). Those are relevant only for the bare console resolution. X11 has its own resolution settings, changed from the desktop GUI, in X11 config files or via CLI arguments (which is how we set it for virtual VNC sessions).

Now RPi 5 could theoretically behave different than RPi Zero W, and Bookworm could behave different than Trixie. But at least the RealVNC package is the exact same in all cases, it has just been copy&pasted into the Trixie suite, no new build. And the kernel is the same version 6.12.47-1+rpt1 as well. It has a ~bookworm suffix on Bookworm, but not sure whether there are any actual differences. Means: worth to give it a try with the above instructions for either of the 2 options.