Create your own desktop environment

What to do if KDE, Gnome and Xfce don’t float your boat? Build your own custom desktop environment, of course!

What’s the best thing about Linux? Security, stability, performance or freedom? It does a cracking job in all of those areas, but another feature we’d highlight is its modularity. As an operating system deeply influenced by Unix, GNU/Linux is designed to be easy to pull apart – and, all being well, easy to put back together again. Major parts of the system are built up from smaller components that can be omitted or replaced, which is one of the reasons why we have so many different Linux distributions.

Sure, this modularity adds complexity at times. But it also adds reliability, as components are designed to work independently, and if one crashes or suffers from some kind of bug, the other parts will (ideally) keep chugging along. So you can replace Bash with another shell, or switch to an alternative SSL library, or even replace your entire init system – as we’ve seen with the migration of major distros to Systemd.

But what about desktop environments? Aren’t KDE, Gnome and Xfce giant, monolithic projects? Not really. They’re built up of smaller programs and libraries that are highly dependent on one another, but it’s possible to strip out certain components or replace them with alternatives. And taking this even further, it’s possible to create a desktop environment entirely from scratch, by cherry-picking a selection of programs, tying them together and making them run simultaneously.

It’s actually rather fun and a good learning experience to create a desktop environment from scratch, so that’s what we’ll do over the next few pages. You’ll be able to choose the components that fit your workflow, and the end result will be considerably lighter and faster than the heavyweights of Gnome and KDE. Plus, you can brag to your friends at the next Linux User Group meeting that you don’t use some generic pre-packaged desktop environment, but you created your own custom setup and have levelled up on the journey to Linux enlightenment.

Here’s the custom desktop we’re going to make using Openbox, PCManFM and Docky — but you can replace all the components with something else!

What is a desktop environment?

Fire up your regular desktop and look around: there are probably panels, notification areas, window titlebars and other bits of furniture. These are all things that the desktop environment (from here onwards, DE) provides, but if we look deeper, we can find other functionality as well. The DE also handles keyboard shortcuts for switching between applications and closing them, along with desktop wallpaper, applets (such as CPU monitors) and fancy window effects.

Now, these features aren’t provided by a single program, but a bunch of them. In Xfce, for instance, running ps ax | grep xfce in a terminal shows all processes that have xfce in their name – and there’s quite a lot of them. Most of the names are obvious, so you can see that xfce4-panel provides the panels that sit around the screen edges, while xfce4-power-manager monitors your battery and handles power events (such as closing the lid).

Gnome and KDE work in very much the same way. It might be tempting to create some kind of insanely awesome hybrid desktop by using individual components from each desktop and mixing them together, but the end result won’t actually be very pretty. As mentioned, the programs in each DE are designed to work together and specifically in those DEs, so if you use a panel from KDE, a power manager from Xfce and a window manager from Gnome, you’ll end up with a mongrel desktop that chews through your RAM banks. After all, you’ll have libraries and other processes from each DE loaded – so it’ll be like running all three at the same time.

No thanks. What we’ll do is choose small and memory-friendly standalone components that don’t rely on anything else, but work well together. As usual in the free software world, there’s a huge range to choose from, so let’s look at some of the top contenders.

Choosing a window manager

Even though we’ll be using individual and standalone programs to make up our custom desktop environment, there are some standards in the X Window System (the base graphical layer of the desktop) which ensure that they work together correctly. First off, let’s look at some window manager options.

  • Name: Openbox

    Designed to be small and fast, Openbox is arguably the best all-round standalone window manager. It’s perfectly possible to use it on its own, but typically it’s combined with other tools. Take LXDE for instance: this is a lightweight desktop environment that uses Openbox to manage windows, and is the desktop of the popular Lubuntu distribution. Openbox is also the default window manager in the now-defunct CrunchBang distro (which is coming back to life as CrunchBang++), and also ArchBang.

    It’s even possible to use Openbox inside Gnome or KDE, replacing their native window managers. Openbox is available in almost every major distro’s repositories, and can be started from a script with the command “crunchbang” (as we’ll see later on).

  • Name: i3

    While Openbox is a traditional mouse-operated window manager, i3 is all about keyboard shortcuts. This makes it a bit hard to grasp early on, as you have to spend a bit of time with the documentation to get used to it, but once you have the keystrokes memorised, you could be hooked. i3 is especially popular amongst coders who want to keep their hands on the keyboard – and not keep reaching over for that pesky rodent.

    Additionally, i3 is a tiling window manager. Instead of a traditional window manager, where you have windows scattered around the screen, some overlapping others, in i3 you organise windows into varying sized tiles (areas) on the screen. So on a widescreen monitor, you could have Firefox occupying exactly 50% on the left-hand side, with two terminal windows occupying the top and bottom sections of the right-hand side. If you have a large screen, you’ll find that the tiling approach works really well.

  • Name: Awesome

    Awesome is another lightweight window manager that’s designed with keyboard usage in mind. It also aims to be compatible with various X standards, and is extensible via the Lua scripting language. The developers describe it as a “framework window manager” – in other words, a base on which you can build a more powerful window manager with Lua customisations and other add-ons.

  • Name: JWM

    JWM is written in plain C and uses the base X libraries, so it has very few dependencies and is easy to compile. It’s designed to get the most out of older computers with limited RAM, but is a good choice when you just want something that gets out of your way. JWM includes its own simple panel, but you may want something more configurable and pretty, as we’ll explore in a moment…

So, that’s just a handful of some of the best window managers around. There are many more to explore though, and as usual, the Arch Linux wiki is a great resource to explore.

Panels, file managers and extras

Once you’ve chosen a window manager, you’ll want to spruce it up with some extras such as a pretty panel (for launching and managing programs), along with a file manager. If you’re an experienced Linux user you may be happy with doing all your file work in a terminal, but we’ll still look at a couple of options.

  • Name: Cairo-Dock

    Cairo-Dock provides a panel that looks rather like Mac OS X’s dock – at least, before the flattening that arrived in 10.10 (Yosemite). Its “3D Plane” mode looks gorgeous, with smooth icons sitting on a glass tray, and as you mouse over the icons they grow slightly in size. By right-clicking an icon you can customise it, or choose the ever-present Cairo-Dock submenu which lets you configure the panel as a whole. By default, Cairo-Dock presents icons for the most popular FOSS programs (providing you have them installed): Firefox, Thunderbird and so forth.

    If you’re going to test your custom desktop in a virtual machine, note that on first startup, Cairo-Dock will ask if you want to use OpenGL. This is useful on real hardware and makes the dock’s effects smoother, but inside VirtualBox it can cause trouble so it’s best to leave it disabled.

Cairo-Dock is loaded with pretty effects and apes Mac OS X rather closely.

  • Name: Docky

    Docky is very similar to Cairo-Dock, although it uses Mono which adds a bit of extra overhead. But it’s also very polished and snazzy, and is capable of the aforementioned OS X-esque 3D look. Docky is available in all major distros, and after installation you can start it simply by entering “docky” at the command prompt. Its default configuration is rather minimal; you’ll only see an anchor icon for configuring docky, along with icons for running programs. You can, however, turn these icons into launchers by right-clicking them and choosing to pin them to the dock. Then they will remain even when the programs are not running.

    With Docky it’s also possible to add extras like weather applets and battery monitors – click the anchor icon to bring up the configuration box, and then choose the Docklets tab for a list. Find one you like and then click the plus (+) button to add it to the right-hand side of the dock.

  • Name: PCManFM

    File managers are ten-a-penny in the Linux world, and most of them provide very little functionality. PCManFM, as used in the LXDE desktop, is one of the most notable: it’s lighter than the heavyweights used in Gnome and KDE, but still packs plenty of punch and does 99% of the jobs you need. It also doesn’t try to be too avant-garde with its design, opting for a familiar layout that anyone can get to grips with very quickly. Plus, it’s pretty much ubiquitous and available in all major distros.

  • Name: XFE

    This isn’t related to Xfce; rather, it’s a very lightweight file manager that uses the FOX graphical toolkit. Its developers describe it as the “file manager of choice for all light thinking Unix addicts”, and while it doesn’t offer a great deal of features over other similarly low-resource programs, it has one benefit: it’s still in development. Consequently, it’s not hard to compile or find in mainstream Linux distros.

XFE is a solid little file manager that doesn’t look super flashy but gets the job done.

Extras: Compositor, background…

It’s possible to add spit-shine to some of the window managers we’ve mentioned (such as Openbox) using themes, but if you really want lots of eye candy to drool over, it’s worth adding a compositing manager. This enables effects such as drop shadows and subtle animations when windows appear, and one of the best is Compton ( It’s really easy to use as well: just start your window manager, and then start Compton to turn on the special effects.

Another thing to consider is your desktop wallpaper. Most lightweight window managers don’t provide a way to do this directly, so you’ll need to find another tool to do it. One especially useful tool for this purpose is Feh (, a command-line driven image viewer that can also set the “root window” image. Yes, this is another use of “root” in Unix parlance, along with the super-admin user and top-level of the filesystem. In X terms, the root window is effectively the background, so if you apply an image to it you set the desktop wallpaper.

Putting it all together

So, let’s do the fun part! We’re now going to turn this collection of components into a fully functioning desktop environment. In this case, we’ll use Openbox as the window manager, Docky as the panel, PCManFM as the file manager, and throw in a bit of Compton and Feh to make it look lovely and pretty.

Because these are all separate programs, we need to create a script to run them all in the correct order. Create a text file in /usr/local/bin/mydesk as root, eg:

sudo nano -w /usr/local/bin/mydesk

Enter the following contents, and use Ctrl+O to save, followed by Ctrl+X to exit the Nano editor.

docky &
pcmanfm &
feh --bg-fill /home/user/desktop.jpg
compton -c --shadow-exclude 'n:e:Docky' &

You’ll also need to make this file executable, with eg sudo chmod +x /usr/local/bin/mydesk. This script starts a bunch of programs, starting with Docky and PCManFM. The ‘&’ symbol after those programs says that we want to run them in the background, and not have the script wait for each one to close. With Feh, you’ll want to change the location of the desktop image to match a picture in your home directory, and note that the Compton line excludes drawing shadows on Docky windows (because they already have their own special effects).

Now, in a normal Linux desktop session we can’t just run this script and expect everything to work, because we already have a window manager, panel and other things running. Instead, we need to tell the login manager (the screen where you enter your username and password) that our script starts its own desktop environment, which we’ll call MyDesk. As root, create the text file /usr/share/xsessions/mydesk.desktop with the following contents:

[Desktop Entry]
Comment=Custom desktop

Once you’ve created a startup script and .desktop file for your session, it will appear in the login manager.

Time to test

Now log out of your current desktop, and at the login screen, choose MyDesk as your session. Enter your username and password, and voila – your custom desktop environment will appear! See the example screenshot: in this case, we’ve clicked on the anchor icon in the bottom-left, chosen “Panel Mode” in the options (to make it use up the full width of the screen), and applied the Matte theme. We’ve also added a workspace switcher Docklet to the right-hand side.

Note that Docky doesn’t include a traditional “Start” menu of programs; instead, you can right-click on the desktop and choose Terminal to open a command line window. Enter a program you want to add to the panel (eg “firefox” or “libreoffice”), and when the program starts, its icon will appear on the panel. Right-click it and choose Pin to keep the launcher there even when the program is not running. And to log out of your custom desktop, right click anywhere on the desktop and choose Exit. (For fine-grained control of the Openbox window manager, it’s worth installing Obconf and then choosing it from the right-click desktop menu.)

And that’s just the beginning! This is merely one example of a desktop that you can create. You could try running cairo-dock & instead of docky & in the /usr/local/bin/mydesk script to try another dock, or change the window manager. It’s important that the window manager is the last line in the script and doesn’t end with an ‘&’ symbol, so that when you exit the window manager, it also exits the entire session and returns you to the login screen.

Have fun experimenting with different combinations of window manager, panel, file manager and other tools, and if you create something spectacular, pop by our forums and share your screenshots with the world. Who knows, maybe there’ll be a whole Ubuntu spin-off based around your desktop one day…


Add a Comment

Your email address will not be published. Required fields are marked *