Problems setting up TigerVNC/XRDP for accessing the existing user desktop session

Required Information

  • DietPi version | 8.8
  • Distro version | bullseye
  • Kernel version | Linux nas 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64 GNU/Linux
  • SBC model | PC (x64 CPU)

Additional Information (if applicable)

  • Software title | TigerVNC, xrdp, MATE
  • TigerVNC fresh, xrdp used in the past (always creating new desktop sessions)

Steps to reproduce

Enable auto-login to desktop for user “dietpi” (using the MATE desktop here)

/boot/dietpi.txt
SOFTWARE_VNCSERVER_DISPLAY_INDEX=0
SOFTWARE_VNCSERVER_SHARE_DESKTOP=1

/etc/systemd/system/vncserver.service
User=dietpi
Environment=HOME=/home/dietpi

sudo -u dietpi /usr/local/bin/vncserver start

Expected behaviour

  • I am able to login to the running desktop session of user dietpi with a remote desktop client (e.g. Windows Remotedesktop, TigerVNC/UltraVNC/TightVNC)
  • I am able to use all keys (running a German setup and keyboard here)
  • Copy & paste does work

Actual behaviour

  • I am not able to log-in immediately. Instead, I have to ssh (via putty) to the machine and do a “systemctl restart vncserver.service”.
  • For being able to use all keys, I have to call a “setxkbmap de” on every desktop session start
  • Copy & paste does not work

Extra details

I followed How to change vncserver session from root to user? - #17 by Joulinar which gave me some hints, but the problems above (also the non-working Copy & Paste) still persist - or I misunderstood something regarding the configuration…

Regarding the first problem, “systemctl status vncserver.service” apparently says that it cannot connect on boot, maybe because the desktop session is not running yet when the service is about to be started? How can I delay the start of the service or do a repeated restart of the service until it is has been started successfully?

Where do I put the “setxkbmap de” best? The issue with non-working keys has also been discussed at Some keys not working · Issue #1227 · TigerVNC/tigervnc · GitHub, but it has been (auto-)closed due to missing additional feedback.

However, if there is another solution (e.g. without using TigerVNC) that allows me connecting to the existing desktop session from Windows or Android, this is also fine. I just want to control the system via remote à la TeamViewer, Windows-VNC etc. e.g. to start UI tools, check their states etc. in a single-user environment.

Thanks a lot in advance!

did you set following within dietpi.txt?

SOFTWARE_VNCSERVER_DISPLAY_INDEX=0
SOFTWARE_VNCSERVER_SHARE_DESKTOP=1

This should connect you to the real desktop. But it would require having the desktop started during boot. Means you need to set dietpi-autostart to start desktop application.

Yes, all done. See my first post, starting with “how to reproduce”. I think/am sure that the desktop starts too late because the log says something like “unable to connect” while "systemctl restart vncserver.service” works a few minutes/seconds later without any problems and no error in the log.

there are a couple of ways to delay service start. You could make service depending on each other or add a sleep timer or create a timer that will start the service with a delay.