This comes in useful when needing to switch between desktop environments on a Ubuntu 20.04 server, when using it as a remote desktop.
Currently Im using this with remote desktops that Im connecting to via xRDP. This may not work for all remote desktop solutions, or all scenarios, however.
Ive added in how to switch desktop environments for Chrome Remote Desktops, and another section for VNC, after realizing the method is different.
If your scenario is different and this method doesnt work for you then please feel free to contact us via the comments section or our contact us page.
Objective
In this tutorial well switch between multiple desktop environments from the command line, on a machine running a Debian based Linux distro.
- Objective
- Prerequisites
- Switching Between Desktop Environments
- Switching to Ubuntu Budgie Desktop Environment
- Switching Between Desktop Environments From the Command Line for Chrome Remote Desktop
- Switching to Ubuntu Budgie Desktop Environment for Chrome Remote Desktop
- Switching Between Desktop Environments From the Command Line for VNC Server
- Conclusion
- Resources & Acknowledgements
Prerequisites
- A machine running a Debian based Linux distro with multiple desktop environments installed. [Im using Ubuntu 20.04]
Switching Between Desktop Environments
To switch between desktop environments on a Debian based distro run the following command:
sudo update-alternatives --config x-session-managerThen you should be presented with the desktop environments you have installed on your system so you can choose one of them:
There are 9 choices for the alternative x-session-manager [providing /usr/bin/x-session-manager]. Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/gnome-session 50 auto mode 1 /usr/bin/gnome-session 50 manual mode 2 /usr/bin/lxsession 49 manual mode 3 /usr/bin/mate-session 50 manual mode 4 /usr/bin/openbox-session 40 manual mode 5 /usr/bin/startlxde 50 manual mode 6 /usr/bin/startlxqt 50 manual mode 7 /usr/bin/startplasma-x11 40 manual mode 8 /usr/bin/startxfce4 50 manual mode 9 /usr/bin/xfce4-session 40 manual mode Press to keep the current choice[*], or type selection number:Then you can fill in the number corresponding to the desktop environment that you want and press enter.
Then you can logout and log back in, and the desktop launched should be the one that you selected.
Switching to Ubuntu Budgie Desktop Environment
The above method doesnt seem to work with Ubuntu Budgie.
What does work, however, is editing the /etc/xrdp/startwm.sh file, by commenting out the last 2 lines, and adding budgie-desktop at the end.
To edit the file run:
sudo nano /etc/xrdp/startwm.shAnd comment out the last two lines and add budgie-desktop at the end:
# test -x /etc/X11/Xsession && exec /etc/X11/Xsession #exec /bin/sh /etc/X11/Xsession budgie-desktopRestart xRDP:
sudo systemctl restart xrdpNow when you log in again you should be using Ubuntu Budgie.
I had found this solution here Froth and Java Ubuntu Budgie and xRDP, but it hasnt worked for me.
Ill update this article when I find a fix.
Switching Between Desktop Environments From the Command Line for Chrome Remote Desktop
To configure Chrome Remote Desktop to use a different desktop environment, then run the following command, replacing CHOSEN_DESKTOP_ENVIRONMENT with the desktop environment that you want.
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/CHOSEN_DESKTOP_ENVIRONMENT" > /etc/chrome-remote-desktop-session'For example, to configure Chrome Remote Desktop to use XFCE you would run:
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'Im not sure of a clean way of listing the paths for each desktop environment, at the moment, but you can run the following command and to see the path for each desktop environment:
sudo update-alternatives --config x-session-managerAs mentioned above, youll be shown something like the following, where you can see the executables for the desktop environments installed on your system under Path.
There are 9 choices for the alternative x-session-manager [providing /usr/bin/x-session-manager]. Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/gnome-session 50 auto mode 1 /usr/bin/gnome-session 50 manual mode 2 /usr/bin/lxsession 49 manual mode 3 /usr/bin/mate-session 50 manual mode 4 /usr/bin/openbox-session 40 manual mode 5 /usr/bin/startlxde 50 manual mode 6 /usr/bin/startlxqt 50 manual mode 7 /usr/bin/startplasma-x11 40 manual mode 8 /usr/bin/startxfce4 50 manual mode 9 /usr/bin/xfce4-session 40 manual mode Press to keep the current choice[*], or type selection number:And youll use the Path for the desktop environment that you want, replacing /usr/bin/CHOSEN_DESKTOP_ENVIRONMENT with it.
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/CHOSEN_DESKTOP_ENVIRONMENT" > /etc/chrome-remote-desktop-session'Switching to Ubuntu Budgie Desktop Environment for Chrome Remote Desktop
The path to Budgie is /usr/bin/budgie-desktop so to switch to it you can run:
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/budgie-desktop" > /etc/chrome-remote-desktop-session'Im not clear on how to find the path to Budgie in a clean command, however you can switch to it, right now. But the above command should work.
Switching Between Desktop Environments From the Command Line for VNC Server
To see how to switch between desktop environments from the command line for VNC, please visit our related article on installing and configuring a VNC server on Ubuntu 20.04, in the Configuring VNC to Use Other Desktop Environments [And Switching Between Them] section.
We cover this exact topic in detail in that section.
We recommend reading through the entire tutorial in order to get some background info on how we set up our server.
For example, we mention that in that tutorial were using TigerVNC, and that TightVNC has not worked for every desktop environment for us.
Conclusion
I hope this article helps you in changing between desktop environments from the command line.
If youre having any issues, or have any feedback, wed love to hear from you in the comments or via the channels on our contact us page.
Resources & Acknowledgements
Alternative way of switching to Ubuntu Budgie Desktop Environment adapted from:
- Froth and Java Ubuntu Budgie and xRDP
Revisions & Updates of this Article
[Mar 23 2021]: Added workaround to switch to Budgie, along with acknowledgements.