Create a totally custom Linux desktop

Titlebars, launchers, panels, notification areas, background images – these are all things we expect in any modern desktop environment. Usually, these features are provided by individual programs, so if you’re running Xfce and enter ps ax in a terminal, for instance, you’ll see xfwm for the window manager, xfce4- panel to provide on-screen panels, and so forth.

If you start terminating these programs, bits of your desktop environment will start to disappear from the screen. KDE and Gnome work in a very similar fashion. Now, this is all good and well, but we’re Linux geeks, right? The defaults do an adequate job, but we run this OS so that we can customise it to our hearts’ content, rip out bits we don’t like, and explore the inner workings of the system.

KDE, Gnome and Xfce look like hugely complicated beasts, but they’re really just a series of programs started in sequence. You can replace these programs individually, or you can choose your own combination of window manager, panel, workspace switcher and so forth – and that’s exactly what we’re going to do in this how-to.

There are many lightweight window managers out there that offer the bare minimum of functionality, so other developers have written the extra components you need to create a fullyfl edged desktop environment. We’ll explore the different choices available, and then show you how to piece them all together into a custom desktop.

If you’re running KDE, Gnome or Xfce, you’ll find that the result is a much snappier and less memory-intensive experience. But most importantly, when your fellow Linux users are talking about upgrading to the latest KDE or Gnome, you can wave your hand and say: “Pfft! Those are old-hat. I made my own desktop environment last night, and I’ll install it for you if you like.” Geek points are coming your way…

Choose a Window Manager

By far the most important component is the window manager. This (normally) provides titlebars so that you can move windows around on the screen, along with buttons to perform actions on the window – maximise, close, etc. The WM also (normally) adds handles to the edges of windows for resizing. Without a WM, your applications could still run, but you wouldn’t be able to move them around or resize them.

adding-windows-manager-via-package-mgr

Adding window managers via your package manager should create new login screen sessions – but we’ll also show you how that works.

There are some novel window managers that take different approaches, such as automatically arranging windows into grids (tiling WMs), and they don’t need titlebars. Here, we’ll describe some of the best choices and explain how to use them. If you install them via your distro’s package manager, you should be able to log out of your current session and choose them in your login screen. If you don’t see an entry for your WM of choice, try selecting a fallback/terminal option in the login screen; some distros provide this. You’ll see an empty terminal window and you can enter the appropriate command to start the WM, as described below.

If you can’t get the WM to start at all, worry not: we’ll show you how to create a new login screen session later on.

  • Name: JWM
  • Web site: joewing.net/projects/jwm/
  • Command to start: jwm

JWM is very bare-bones, being written in C and only making use of the core X libraries as dependencies. Consequently, it’s screamingly fast. JWM has a fairly usable default panel, containing a program menu, workspace switcher and taskbar, but you’ll probably want a more featureful panel from the options we’ll look at later.

By default, the program menu (also available by left-clicking on the desktop) contains only entries to start a terminal, lock the screen and log out – you can customise this by editing /etc/jwm/ system.jwmrc (or /usr/local/etc/jwm/ system.jwmrc if you built it from source).

This XML-based configuration file is easy to understand, and via it you can also customise the WM’s fonts and keybindings.

  • Name: Openbox
  • Web site: www.openbox.org
  • Command to start: openbox

Openbox is part of the ‘box’ family of window managers, which includes Fluxbox and Blackbox (the original, from which the others are derived). It’s perhaps the most popular low-fat window manager, and is used in the LXDE desktop. Openbox’s default configuration is as bare-bones as it gets: as soon as you start it, you’ll see a grand total of nothing. Just your mouse pointer in the middle of the screen.

openbox-configuration-tool

Openbox has its own configuration tool (obconf), which obviates the need to fiddle with text files.

Right-click, however, and a small menu will pop up, from which you can open a terminal window, launch a web browser, or run the configuration tool. It’s this tool that makes Openbox our favourite choice for custom desktop environments, because you can configure almost everything in the window manager without having to poke around inside text files. Plus, while Openbox is very limited on the feature front, it’s highly standards-compliant and interacts excellently with other tools.

The keyboard shortcuts are typical: Alt-Tab to cycle through windows, Alt-F4 to close programs, and Ctrl-Alt-Left/ Right cursor keys to switch between different virtual workspaces.

  • Name: Ratpoison
  • Website: ratpoison.wxcvbn.org
  • Command to start: ratpoison

Here’s a very different kind of window manager: it’s built around a concept called ’tiling’. Instead of the usual system of draggable windows that can overlap one another, in Ratpoison windows are allocated areas on the screen. It takes a while to get used to, but as you learn the keybindings used to manage windows, you become less and less dependent on the mouse (hence the name).

On first start, Ratpoison is completely bare, and you’ll find that the mouse does nothing. Hit Ctrl-t followed by !, though, and a tiny box will appear in the top-right corner, which lets you enter a command (eg, xterm). When you launch a program, by default it will appear in full-screen mode, and once you have multiple windows open, you can switch between them using Ctrl-t, followed by n and p (next and previous). Enter Ctrl-t-w to show a numbered list of windows and Ctrl-t followed by a number to switch to a specific window. Now, the real fun begins in tiling mode. With a few windows open, hit Ctrl-t s to split the screen vertically into two zones, called frames. The current window will appear in the top frame, while the previous window will appear underneath. Hitting Ctrl-t, followed by S (capital letter) splits the screen horizontally. This is excellent if you have a large and high-resolution monitor, as you can, for instance, create a large frame for your web browser, and have a couple of smaller terminal windows sitting next to it.

To switch between frames, hit Ctrl-t, followed by the cursor keys (eg, the down key to switch to the frame underneath). You can make a frame full-screen again with Ctrl-t-Q. For a full list of keybindings, enter Ctrl-t-?, and visit the Ratpoison wiki for details on more features in the WM.

Other window managers worth looking at include Sawfish, WindowLab and Pekwm.

Choose a panel

So, we have the job of managing windows sorted out. Now we want a panel for launching programs, switching between windows and workspaces, showing a clock and so forth. As mentioned, JWM includes a simple panel, but we’ll look at some more featureful options here.

  • Name: Docky
  • Web site: www.go-docky.com
  • Command to start: docky

We absolutely love the description on Docky’s web site: “If there ever was something made of pure awesome in the history of mankind, then its name is Docky”. And, you know, we can’t really disagree – it’s very cool indeed. Docky is fairly heavy for a panel, with a lot of dependencies, so if you’re creating a custom desktop for low-memory machines it’s best to try the other options.

You should be able to find Docky in most distros’ package repositories (it’s just a sudo apt-get install docky away in Ubuntu-based distros), and when you start it, you’ll see a small black panel at the bottom of the screen. There’s a single static icon that shows an anchor – this opens up the Settings dialog. From here, you can choose Panel mode, which extends Docky to fill the width of the screen, and change the theme (some of them are truly gorgeous). Switch to the Docklets tab of the Settings dialog to add other static items to the panel, such as a clock, workspace switcher and battery monitor.

Docky doesn’t include a main menu, which is a bit limiting, but if you start programs via your window manager you’ll see icons for them appear on the panel. Right-click on an icon and choose ‘Pin to dock’ to make the icon remain in the panel, even when you close the program. In this way, you can populate your panel with your most-used programs, so the lack of a main menu isn’t a huge deal.

  • Name: Cairo-Dock
  • Web site: glx-dock.org
  • Command to start: cairo-dock

If you want eye candy, Cairo-Dock delivers it in spades. Its 3D Plane view is strikingly similar to Mac OS X’s dock, with lush reflection effects and patterned lines separating different areas. Icons grow in size as you run the mouse pointer over them, and if you hover over a folder, a preview of its contents springs up onto the screen. The whole thing is really beautiful – but it requires some oomph from your graphics card, of course.

cairo-dock-mac-osx-feel

Fancy adding some Mac OS X-esque spit shine to your custom desktop? Cairo-Dock is what you need.

Unlike Docky, Cairo-Dock does include a main menu based on system settings; in other words, it’ll show the same items that you see in other window managers and desktop environments. You can right-click on any item to configure it, or go into ‘Cairo-Dock > Configure’ to customise the panel itself. And it’s immensely configurable, with plenty of add-ons to enable, keybindings to tweak and size and position settings to change.

  • Name: WBar
  • Web site: code.google.com/p/wbar/
  • Command to start: wbar

This is the lightest of the three panels covered here, and starts up almost instantly. It features a transparent background, animated growing icons when you mouse over them, and a graphical configuration tool (install wbar-config alongside the panel itself). By default, it’s displayed vertically, but you can click on the top-most icon to change this, along with other settings.

Add and remove launchers via the Icons tab, and if you want the panel to act more like a taskbar, there’s an option for this under the Preferences tab. To customise the zoom levels, transparency effects and distance between icons, see the Effects tab.

If none of these docks float your boat, try tint2PerlPanel or the Avant Window Navigator. The last two are a bit dated now, but you can still find packages for various distros on the net.

Choose some extras

Most lightweight window managers don’t include any way to set the desktop background image, so you’ll need another tool for that. hsetroot is a simple little program that’s available in most distros as a standalone package, or occasionally as part of HackedBox (another small WM). Once you have it installed, using it is as simple as:

hsetroot -full /path/to/image. jpg

That places the full image on the screen, without any changes. Other options include -center, -tile and -fill (to stretch it). You can also use PNG images and other formats.

If your choice of dock or panel doesn’t include a virtual workspace switcher, you’ll need to get a standalone one. There isn’t a massive variety of choices in this area, but the one we recommend (because its dependencies are minimal and it works almost everywhere) is NetWMPager. Go to to NetWMPager’s project site and grab the latest source code (2.04 at the time of writing) and build it like this:

tar xfv netwmpager-2.04.tar.bz2

cd netwmpager-2.04/

./configure

make

sudo make install

If you encounter an “undefined reference to symbol XGetWindow Attributes” problem after the make step, edit config.mk and change the XFT_LIBS line so it reads like this:

XFT_LIBS = -lXft -lX11

Save the file and run the last two steps again. Now you can start it with netwmpager, and you’ll see a pager window showing desktops in the bottom-left corner.

By default, it’s very small and autohides; to change this, edit /usr/local/ share/netwmpager/config-example and modify the geometry and auto_hide lines. If you need a notification area (aka system tray), Stalonetray is a fine example. It’s available in Ubuntu’s package archives and also via source code at stalonetray.sf.net – if you’re compiling it by hand, extract it and run the ./configure, make and sudo make install steps as above.

Then launch it like so:

stalonetray -geometry 5x1+50+20

This creates a notification area five slots wide by one slot high, 50 pixels across and 20 down (from the top-left corner of the screen). You can, of course, make it any size and place it wherever you want.

Put it all together

Now we can put the components together, and make a desktop environment. You can use any combination of the previously mentioned programs; in our case, we’ll use Openbox, Docky, hsetroot, NetWMPager and Stalonetray. The first thing to do is to create a script that launches the required programs. For our custom desktop, we’re putting this in / usr/local/bin/mikedesk-start:

#!/bin/bash

docky & hsetroot -fill /usr/share/

backgrounds/space-02.jpg &

netwmpager &

stalonetray -geometry 5x1+0+0 &

openbox

The & after the commands here means ‘run them in the background’ — ie, so they can all run at the same time, and don’t wait for each other to finish. It’s important that your window manager goes on the last line, without the &, otherwise the session will close immediately.

Save the file and make it executable (eg, sudo chmod +x mikedesk-start). The next step is to create a login screen session, so make a new file called something like /usr/share/xsessions/ mikedesk.session with the following contents, customised for your setup:

[Desktop Entry]

Name=MikeDesk

Comment=Mike Desktop Environment

Type=XSession

Exec=/usr/local/bin/mikedesk-start

TryExec=mikedesk-start

Save it, log out of your current session and you should see a new one in your login manager. Choose it, log in and enjoy the fruits of your labour. Congratulations, you are now officially awesome.

custom-linux-desktop-final-result

And here’s the result of our work: a desktop environment built with our own selection of components.

  • GreenRover

    Great article man.

  • daml112

    nice