1. Overview

In this tutorial, we’ll talk about desktop environments and how to set up our favorite one to start up with our system.

2. Display Manager, Windows Manager, and Desktop Environment

Before discussing how to achieve our goal, we need to define three keywords that will pop up throughout the tutorial.

A display manager (DM) is a utility that starts during system booting. It presents the user with a login screen and potentially a selector on what to display after a successful login. We usually employ a DM to automate the access to our system and to get a graphical user interface (GUI): either with a windows manager or a desktop environment.

A windows manager (WM) is a piece of software only in charge of placing the windows of each program on the screen. It may also control what appearance these windows have. As they mostly work in conjunction with a desktop environment, we will focus on the setup of desktop environments themselves. However, the procedure for WM is similar, as a WM shares many features with desktop environments.

A desktop environment (DE) is a bunch of programs running in the same system to control its GUI. Some elements of a DE are windows (controlled with WM), toolbars, folders, widgets, etc. They provide an alternative interaction mechanism to the command-line interface.

To sum up, all three DM, WM, and DE are different, and they can coexist even when coming from different development teams. Nevertheless, they work better when all three are created together, providing a more seamless experience for the user.

3. Setup Procedure

There is a large array of choices for DE. Some of the most popular ones are GNOME, KDE, LXDE, MATE, and Xfce. Moreover, there are multiple display managers: console-based as nodm or with graphical interfaces such as GDM (for the GNOME desktop environment), LightDM (cross-desktop environments), LXDM (developed for the LXDE), and SDDM (successor to the display manager of KDE). The procedure may be slightly different for each DM, although the outlines that we will discuss here are quite general and can work with any of them.

The first thing that we have to do is to list the sessions that are available to our display manager. They are located in /usr/share/xsessions:

$ ls /usr/share/xsessions
i3.desktop  
gnome.desktop
mate.desktop
xfce.desktop

To make a display manager select a session by default, we need to find the configuration file for that display manager in particular. The documentation of each DM should refer to this location. For example, the file for KDE is located in $HOME/.dmrc. To specify the DE, we have to add the following content to the file:

[Desktop]
Session=i3

These are other possible locations where we can find this configuration file:

  • /etc/sysconfig/desktop
  • $HOME/.xinitrc
  • /var/lib/AccountsService/users/$USER

After having changed this, our system should launch the chosen DE after having logged in to the DM.

4. Missing Desktop Environment Session File

The previous section assumes that there is one session file for the DE that we want in the /usr/share/xsessions directory. If we don’t have it for our DE, we can create one custom session file for any DE not listed. We can copy any of the other session files or use the following template:

[Desktop Entry]
Name=#name_of_DE
Exec=#DE_executable
TryExec=#alternative_DE_executable
Type=Application
X-LightDM-DesktopName=#displayed_name_of_DE

We need to replace those elements, starting with a # with the corresponding value for our desktop environment.

5. What to Do if Everything Else Fails

If we have already tried everything else and cannot make it work, there is another approach to achieve this. It consists of moving everything from the /usr/share/xsessions directory to another directory. Then, we only copy back the session file of the desktop environment that we want.

$ ls /usr/share/xsessions
i3.desktop  
gnome.desktop
mate.desktop
xfce.desktop
$ mkdir $HOME/all_xsessions
$ mv /usr/share/xsessions/* $HOME/all_xsessions/
$ cp $HOME/all_xsessions/i3.desktop /usr/share/xsessions/* 
$ ls /usr/share/xsessions
i3.desktop  

With this approach, we can limit the possible options that our DM has to start. Therefore, it will start with the only available session file.

6. Conclusion

In this tutorial, we have seen methods to set up our preferred desktop environment (DE) to automatically start after having successful login through our display manager (DM) of choice. There is a large variety of both DE and DM, but we have discussed the more common options, and the procedure for others should be similar.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.