VNC display issue with the plank dock

Hi everyone.

I have an administrator user on Ubunutu Mate 20.04 with tiger vnc server installed, I quite like the plank dock option under Mate Tweak > Panel > Panel Features > Enable Dock.
My problem is that I can only have the dock displayed on the desktop of administrator locally, when I log in as administrator remotely via vnc viewer, I can't see the dock. I tried to launch plank from terminal but I got this error:

$plank
[AbstractMain:255] Only X11 environments are supported.

On local desktop GUI the session type is x11:

$echo $XDG_SESSION_TYPE
x11

On vnc viewer the session type is unspecified:

$echo $XDG_SESSION_TYPE
unspecified

I found a workaround here:
https://bugs.launchpad.net/ubuntu/+source/plank/+bug/1903496
On vnc viewer I need to open terminal and run the following command as administrator:

$XDG_SESSION_TYPE=x11 nohup plank >/dev/null

It's really annoying that I have to run this command in the terminal when I log in from vnc viewer. I tried to run this command by adding to the Startup Applications but it won't launch the dock. I also tried to create a script /home/administrator/plank.sh to run this command:

#!/bin/bash
su administrator -c "XDG_SESSION_TYPE=x11 nohup plank >/dev/null"

I can run this command without a problem as root user, but I need to start this script automatically when the pc start up. I created a service under /etc/systemctl/system/plank.service:

[Unit]
Description=dock auto start script
[Service]
ExecStart=/home/administrator/plank.sh
[Install]
WantedBy=multi-user.target

It just won't work, the service would fail when I start it.
Is there a way to set up a default value to XDG_SESSION_TYPE for vnc user? Any one has any experiences or thoughts on this? Thanks!

Hey guys.

I'm back with this temporary solution that I edit /home/administrator/plank.sh to

XDG_SESSION_TYPE=x11 nohup plank >/dev/null

I'm using xdotool to launch this script automatically and I also use a script to run the xdotool commands: /home/administrator/xodotool.sh
https://linuxhint.com/xdotool_stimulate_mouse_clicks_and_keystrokes/

And I add this command to the vnc config file: /home/administrator/.vnc/xstartup

sleep 10s&&/home/administrator/xdotool.sh

I know this is a stupid way to solve this problem but at least I don't have to manually launch the script now, vnc would do it for me thanks to xdotool. I wish I could find system file that launches plank when I check Mate Tweak > Panel > Panel Features > Enable Dock so that I could try modify the default plank configuration.

Hopefully this XDG_SESSION_TYPE issue on vnc can be solved in the future. Thanks!

Phew! I had this problem solved after one month :joy: If you are using the 64bit Ubuntu Mate 20.04 with Tiger vnc then I think this would work for you:
Edit your xstartup file at ~/.vnc/xstartup

My files was:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /usr/bin/mate-session &

My new xstartup file now:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
XDG_SESSION_TYPE=x11
exec /usr/bin/mate-session &

Now that every time before your vnc server starts up the Mate desktop environment, the XDG_SESSION_TYPE would be set to x11. I can finally have plank on my vnc viewer now!

1 Like