How to Create a Linux Desktop Environment


Have you tried many desktop environments but nothing suits your taste? Or maybe you like some components of a desktop environment and dislike others. Maybe it’s time to consider creating your own desktop environment…

How to create a desktop environment?

You can easily create a desktop environment by assembling different components from existing desktop environments and other independent programs. It’s best to know the general components of a desktop environment before creating one, but it’s not necessary. Here we will show you how to create your own desktop environment step by step.

Step 1: Create the Session Bash Script

To create a minimal desktop environment, you should at least put a window manager in it. In this guide, we will be using the kwin window manager. But you can use any window manager you want.

To install kwin on Ubuntu and Ubuntu-based systems, type the following command in the terminal:

 sudo apt install kwin --no-install-recommends 

Without the –no-install-recommends option, apt will install the whole kde desktop environment.

In addition to the window manager, we will add the plank dock to the desktop environment. To install it type:

 sudo apt install plank

Now let’s create the session bash script. If you don’t already know, a bash script is a normal text file where you enter a sequence of commands. When the file is executed, it runs the contained commands line by line, saving you from typing each command yourself in the terminal.


Our script will contain the programs that our desktop environment will have. We will put the script in /trash can phone book. So open the terminal and navigate to /trash can by typing the following command:

 cd /bin

Then create the script with the following command (we will call it

 sudo touch 

Open the file as root using your text editor, for example nano:

 sudo nano 

You can replace nano with any text editor like gedit or xed.

Then place the following line at the top of the script.


This line tells the terminal to run this script using bash.

Next, type the commands for the programs you want to put in the custom desktop starting with the window manager (in this case kwin).

kwin &


The ampersand (&) after a command causes it to run in the background so that the next command is executed without waiting for the previous command to exit. We need to do this because the programs that make up the desktop environment need to run at the same time.

This script represents the desktop session, as long as this script is running, the session will continue to run. When this script completes, the session will close and you will be taken to the login screen as if you had logged out.

This is why it is important not to put an ampersand (&) after the last command. If this happens and the last command is sent in the background, the script will close and the session will close as soon as it starts.

After saving the script, give it execute permission by entering the following command:

 sudo chmod +x 

Step 2: create the desktop file

To make our custom desktop visible when logging in, we need to create a .desktop drop in /usr/share/xsessions which will point to the script. To access this directory, in the terminal type:

 cd /usr/share/xsessions 

Then create the file and open it by:

sudo touch custom_de.desktop
sudo nano custom_de.desktop

Inside the file, put the following lines:

[Desktop Entry]
Name=Custom DE
Comment=My awesome desktop environment

For Exec=, enter the location of the session script you created earlier.

nano_text_editor desktop entry

Step 3: Launch the custom desktop environment

To launch your desktop environment:

  1. Sign out
  2. Find the list of installed desktop environments
  3. Select the newly created desktop environment
  4. Login again

To quit this session, kill the last program in your session script using the pkill command:

 pkill plank 

Make your desktop environment more complete

Congratulations! You have created your own desktop environment.

But there are still a few components missing. It’s time to add a wallpaper and a panel.

There are many wallpaper creators. A good choice is Komorebi, which gives you the option to set videos as wallpapers, and it also displays desktop icons.

To install komorebi, download the deb package from the GitHub repository, install it, and run it.

For the panel, we will use lxqt-panel, to install it on Ubuntu:

 sudo apt install lxqt-panel 

Don’t forget to put the lxqt-panel command and komorebi in the session script followed by the ampersand (&). Use the full path of the komorebi command (/System/Applications/komorebi).

nano_text_editor board

You can also add Ulauncher, a useful application launcher. This will make the desktop experience more complete:

sudo add-apt-repository ppa:agornostal/ulauncher && sudo apt update && sudo apt install ulauncher

You can add as many programs as you want, customize your desktop according to your needs. Also consider adding a notification manager.

How to set GTK and Icon themes

In other desktop environments, you can change GTK themes and icons using a GUI utility like gnome-tweaks or something else. In our case, we don’t have these utilities, but don’t worry because you can also change themes from the command line using the gsettings command.

For gsettings to have any effect, dbus must be running.

Dbus is started using launch dbus. Just add dbus launch bash at the beginning of your script.

nano_text_editor launch bash

Then, exit the session and reconnect. To get the currently applied GTK theme:

 gsettings get org.gnome.desktop.interface gtk-theme 

To set the GTK theme to the Canta theme for example, type:

 gsettings set org.gnome.desktop.interface gtk-theme Canta 

The theme you are going to define must be in /usr/share/themes phone book. The name of the theme is its folder name.

Linux desktop with mountain wallpaper

The ultimate personalization experience

While creating your own desktop environment is a refreshing experience, it may not result in a full desktop experience the first time. But by adding other programs, you will create a better desktop environment. If you like to build things, you might like ArchLinux because it lets you build your own Linux distribution.

switch to a window manager
7 things you need to know before switching to a window manager

Want to replace your current desktop environment with a window manager? Here are some things to know before making a decision.

Read more

About the Author


Comments are closed.