How to change to other desktop environment on VNC sessions?

On my system I will use VNC to login. But at this time, after connect to the pc, I get the automatic login with unity desktop. What I have to do, to have gnome desktop on VNC connection instead of unity?


Solution 1:

It should be sufficient to create a suitable ~/.vnc/xstartup file in your account on the remote host, including the line

gnome-session --session=your-preferred-session &

For example, a minimal file for a gnome-classic session might be

#!/bin/sh

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

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

gnome-session --session=gnome-classic &

The text of your-preferred-session will depend on what desktop packages you have installed - which you can check by looking in the /usr/share/xsessions directory i.e.

$ ls /usr/share/xsessions/
awesome.desktop        gnome-classic.desktop  gnome-fallback.desktop
gnome.desktop          gnome-shell.desktop     ubuntu-2d.desktop     xfce.desktop

The xstartup file can also be used to start non-gnome desktop sessions, for example

if which startxfce4 > /dev/null; then
    exec startxfce4 
fi