2

My user's crontab contains:

@reboot sleep 60 && /home/mslinn/.local/bin/vncserver4 >/dev/null 2>&1

/home/mslinn/.local/bin/vncserver4:

#!/bin/bash

rm -f /tmp/.X4-lock
rm -f /tmp/.X11-unix/X4

vncserver :4 -depth 24 -geometry 3840x2160

~/.vnc/xstartup:

#!/bin/sh

# Change "GNOME" to "KDE" for a KDE desktop, or "" for a generic desktop
MODE="GNOME"

#Uncommment this line if using Gnome and your keyboard mappings are incorrect.
#export XKL_XMODMAP_DISABLE=1

# Load X resources (if any)
if [ -e "$HOME/.Xresources" ]
then
        xrdb "$HOME/.Xresources"
fi

# Try a GNOME session, or fall back to KDE
if [ "GNOME" = "$MODE" ]
then
        if which gnome-session >/dev/null
        then
                gnome-session --session=ubuntu-2d &
        else
                MODE="KDE"
        fi
fi

# Try a KDE session, or fall back to generic
if [ "KDE" = "$MODE" ]
then
        if which startkde >/dev/null
        then
                startkde &
        else
                MODE=""
        fi
fi

# Run a generic session
if [ -z "$MODE" ]
then
        xsetroot -solid "#DAB082"
        x-terminal-emulator -geometry "80x24+10+10" -ls -title "$VNCDESKTOP Desktop" &
        x-window-manager &
fi

The vnc viewer shows: vncviewer

$ ps aux|grep [g]nome
mslinn      1064  0.0  0.0 397064  8004 ?        SLl  Jul13   0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
mslinn      1104  0.0  0.0 171112  6224 tty2     Ssl+ Jul13   0:00 /usr/libexec/gdm-x-session --run-script env GNOME_SHELL_SESSION_MODE=ubuntu /usr/bin/gnome-session --session=ubuntu
mslinn      1206  0.0  0.0 231768 15112 tty2     Sl+  Jul13   0:00 /usr/libexec/gnome-session-binary --session=ubuntu
mslinn      1305  0.0  0.0 100556  4992 ?        Ssl  Jul13   0:00 /usr/libexec/gnome-session-ctl --monitor
mslinn      1317  0.0  0.0 732780 17352 ?        Ssl  Jul13   0:00 /usr/libexec/gnome-session-binary --systemd-service --session=ubuntu
mslinn      1340  1.5  0.9 3976100 299252 ?      Ssl  Jul13 102:51 /usr/bin/gnome-shell
mslinn      1405  0.0  0.0 583104 20208 ?        Sl   Jul13   0:00 /usr/libexec/gnome-shell-calendar-server
mslinn      1481  0.0  0.0 2940440 29280 ?       Sl   Jul13   0:00 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notifications
mslinn      1483  0.0  0.0 162816  7152 ?        Sl   Jul13   0:00 /usr/libexec/at-spi2-registryd --use-gnome-session
mslinn      1619  0.0  0.1 711464 45248 ?        Ssl  Jul13   0:00 /usr/libexec/xdg-desktop-portal-gnome
mslinn      1722  0.0  0.0 2948104 27208 ?       Sl   Jul13   0:00 /usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver
mslinn    562376  0.1  0.3 1231980 118068 ?      SLl  00:21   0:03 gnome-control-center
1
  • 1
    Hi, any luck on this problem? I met the same situation, having googled it for 1 hour but still cannot find any solution... Commented Feb 25, 2023 at 7:51

2 Answers 2

0

Check if Wayland is used.
Method 1:
Check vnc log file, search warning like below.
(xfwm4:xxx): Gtk-WARNING **: x:x:x.x: cannot open display: wayland-0

Method 2:
Run loginctl to list all session ID.
Run loginctl show-session <ID> -p Type to verify session type.

Disable wayland

  • sudo vi /etc/gdm3/custom.conf.
    Add WaylandEnable=false to the end.
  • sudo systemctl restart gdm3

Install X11
sudo apt update
sudo apt install xorg openbox

Reboot
sudo reboot

Run loginctl then loginctl show-session <ID> -p Type to verify again.

Start VNC Server.

1
  • Disabling Wayland means another windowing system would be required. I do not want to install another.
    – Mike Slinn
    Commented Jun 13 at 12:21
-2

RealVNC doesn't support Wayland which Ubuntu 22.04 uses by default so you need to disable it as per RealVNC's Ubuntu instructions below:

"Wayland is not supported, so if the remote computer is running Ubuntu 18.04 LTS+, edit the /etc/gdm3/custom.conf file, uncomment WaylandEnable=false, and reboot in order to remotely access the login screen."

Also you'll need to install the following packages : xfce4 xfce4-goodies tightvncserver

Finally, you'll need to add the following line at the end of ~/.vnc/xstartup.kept : startxfce4 &

1
  • 3
    Thanks, but you are echoing the advice shown all over the interwebs. I have no desire to install xfce4. My purpose is to use the default Ubuntu desktop. Furthermore, I do not care if RealVNC is used, or some other implementation, such as TightVNC as I pointed out, and you suggested later in your reply.
    – Mike Slinn
    Commented Oct 7, 2022 at 16:19

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