I managed to answer the Alternative part of my question, i.e. use vnc4server or tightvncserver to start a Xubuntu session instead of a plain XFCE session. This is separate from LightDM, which can then be stopped or put on manual. I'll investigate Nicholas's suggestions later.
This is equivalent to logging in via LightDM with a Xubuntu session, it remains alive if my vnc connection dies or I disconnect, and I get to enjoy the Xubuntu customizations.
To do that, make ~/.vnc/xstartup
contain just the following:
#!/bin/sh
export XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
export XDG_DATA_DIRS=/usr/share/xubuntu:/usr/local/share/:/usr/share/:/usr/share
vncconfig -iconic &
. lightdm-session
You can replace . lightdm-session
with exec startxfce4
or startxfce4 &
. The former is really what LightDM calls, but it calls xfce4-session in the end.
This then starts a Xubuntu session, rather than a plain XFCE one, and you can stop LightDM altogether if X/keyboard access is not needed.
You can configure a daemon by placing the following in /etc/init/vncserver.conf
:
start on runlevel [2345]
stop on runlevel [016]
post-start script
su USER -c "vncserver :1 -geometry 1280x800 -depth 16 -localhost -SecurityTypes None"
end script
post-stop script
su USER -c "vncserver -kill :1"
end script
Then start/stop it with start vncserver
. The above is for vnc4server and will start Xvnc listening only on 127.0.0.1 and will not require a password. This is handy for me as I use an ssh tunnel anyway:
ssh -L6901:127.0.0.1:5901 USER@HOST.DOMAIN.COM
If you use tightvncserver, then delete the option -SecurityTypes None as it doesn't understand it. Note that tightvncserver always asks for a password (you can't make it passwordless).
NOTE: if USER above is not root, or if you run "vncserver :1 [options]" as non-root, then inside XFCE there will be issues sudo-ing into GUI apps because the underlying sudo-ed app will not find an X display. I haven';t yet found a fix for this. With x11vnc it works because x11vnc connects to an existing X session, including the :0 one.
Best Answer
From
man x11vnc
So you probably want
-shared -forever