Installation of x0vncserver
On lubuntu 22.04 I have installed x0vncserver by the command:
sudo apt-get install tigervnc-scraping-server
May be it is better that you remove your current VNC server.
After the installation I have executed the following steps:
> mkdir -p ~/.vnc
> vncpasswd
# insert the VNC password (not create a password for only Viewer
# connection when the command ask you)
Creation of the x0vncserver starting script
Create the following script /usr/local/bin/start-x0vncserver.sh:
#!/bin/bash
export XAUTHORITY="/var/run/lightdm/root/:0"
VNC_BIN=/usr/bin/x0vncserver
PARAMS="-localhost no -passwordfile ~/.vnc/passwd -display :0"
($VNC_BIN $PARAMS)
exit 0
Previous script enable VNC Client to connect to the display:0 (see the parameter -display :0 for the VNC server x0vncserver).
This script must be executable so execute:
> sudo chmod +x /usr/local/bin/start-x0vncserver.sh
Enable the autostart of VNC Server
After that you have to enable the execution of the script /usr/local/bin/start-x0vncserver.sh at boot by the Autostart of Ubuntu. On lubuntu 22.04 I have used the menu Preference->LXQT Settings->Session Settings->Autostart (from Start button).
On your Ubuntu distribution I don't know exactly where you can find the option for Autostart but I'm sure is under the Preferences menu of the Start button.