Tiling Window Managers, and Getting Started with dwm

Tiling window manager?

A window manager is perhaps the most ubiquitous yet invisible aspect of any modern desktop operating system. This software manages the placement of windows and dictates where newly opened windows will show up. Whenever you resize, move, minimise/maximise a window, or click to focus it, you are interacting with a window manager. This article discusses floating and tiling window managers.

Here is a list of a few popular window managers used on Linux desktops environments:

  • Kwin on KDE
  • Metacity on GNOME 2
  • Mutter on GNOME 3
  • Compiz on Unity
  • Xfwm on XFCE
  • Openbox on LXDE

It is worth mentioning that a window manager (WM) is only concerned with managing existing windows and handling newly opened ones. How these windows are opened is of no concern to the WM. Hence, desktop environments like KDE, GNOME, etc., often provide extra applications like panels, application launchers, system trays, file managers, etc., to provide a complete and consistent set of tools to the end user.

It shouldn’t come as a surprise that there are a variety of WMs. In this article, I will cover two kinds of WMs — floating and (surprise!) tiling. All the WMs mentioned earlier are the floating variety. As the name implies, they represent windows as floating rectangles on the desktop — freely resizeable and movable. The floating approach to window management has been the most widely used (even Windows and Mac use it), but it has some fundamental flaws, which most of you might have experienced at some point or the other.

Problems with conventional floating WMs

The main problem with floating WMs is the fact that they are not really designed to facilitate side-by-side viewing of more than one window. The idea of having freely floating windows means that they can (and will) overlap each other. Having to manually move and resize windows to prevent them from covering the mission-critical parts of one another can get pretty tiresome, once you have more than a handful open. Even if you have all the open windows arranged the way you want, you will still have to go through the resize-move-rinse-repeat rigmarole each time you add or remove windows from the layout.

Another problem is the over-reliance on the mouse. Anyone with a display larger than, say, 45.72 cm (18 inches) would have felt the pain of having to move the mouse from one corner of the screen to another, and then back to the initial position — a fairly typical motion on a Windows PC, where the Start menu is in the bottom-left corner of the screen, and the min/max/close buttons at the top-right corner of a maximised window.

Generally, the larger the monitor, the more you will find the need to get acquainted with keyboard shortcuts instead of using the mouse. These are precisely the areas where tiling WMs shine.

An introduction to tiling WMs

A tiling WM does not place windows as floating entities, but as non-overlapping rectangular tiles (think of tiles on a wall), which are part of a larger rectangle (think of the wall itself, or in this case, your monitor). In this case, the faux 3D illusion of floating WMs is done away with because 2D surfaces — again, your monitor — are not all that good at handling the z-axis ordering among overlapping windows. So they automatically perform the resize-move drill each time you open or close a window, using a predefined algorithm to generate a non-overlapping layout from the existing windows.

You may think that the automatic handling of windows in tiling WMs takes away the fine-grained control you can have over their placement in floating WMs — but once you use tiling WMs long enough, you will find that your floating layout resembles a tiling WM-generated layout anyway.

Did I mention that all window management actions in tiling WMs can be performed using only the keyboard? In fact, most tiling WMs actively discourage the use of the mouse altogether. Tiling WMs also strive for the utmost minimalism, where nothing is preconfigured or assumed to be a sensible default for the user. Configuration usually involves editing a plain text file or, in extreme cases, the source code.

While this kind of minimalist approach may not be suitable for all, its main advantage is that when you are done configuring, your WM behaves exactly the way you want it to.

A few popular tiling WMs are:

  • awesome: Written and configured in Lua.
  • xmonad: Written and configured in Haskell.
  • dwm: Written and configured in C.
  • i3: Configured via a plain text file. It follows a tabular approach to managing windows.

Installing and configuring dwm under Ubuntu

dwm is an ultra-minimal tiling WM written in C. Ubuntu 11.10 offers a binary package, but it is quite pointless, since the only way to configure dwm is by editing its source code and recompiling. Instead, let us grab the latest source directly from the project website.

First install the dependencies needed to compile dwm, along with the package suckless-tools which contains a bunch of utilities for use with dwm:

$ sudo apt-get install build-essential libx11-dev libxinerama-dev sharutils suckless-tools

Now grab the dwm source code from the project website, and extract it locally, as follows:

$ cd /usr/local/src
$ sudo wget http://dl.suckless.org/dwm/dwm-6.0.tar.gz
$ sudo tar xvzf dwm-6.0.tar.gz
$ chown -R `id -u`:`id -g` dwm-6.0
$ cd dwm-6.0

Before proceeding further with compilation, have a look at the README file. It tells you to modify the config.mk file to match your system. However, the defaults work just fine on a normal Ubuntu system, so go ahead and compile!

$ sudo make clean install

At this point, dwm is installed as /usr/local/bin/dwm, but you still need to add an entry for dwm so that it shows up as an option in your login screen. For this, install dwm from the repositories — which, as I said before, is not of much use, but it will also install the file /usr/share/xsessions/dwm.desktop, which is what we need. So we will back up this file, remove the dwm package, and restore our copy of the file.

$ sudo apt-get install dwm
$ sudo cp /usr/share/xsessions/dwm.desktop{,.bak}
$ sudo apt-get purge dwm
$ sudo mv /usr/share/xsessions/dwm.desktop{.bak,}

Now we are all set to log in to our dwm setup! So log out, and log back in to a dwm session to be greeted with a shiny new desktop that looks something like Figure 1.

Default dwm desktop

Figure 1: Default dwm desktop

There you go, unabashed simplicity, right there. No oversized icons to waste screen space, no system trays, taskbars or panels to distract you and no apparent way to launch applications. What you do have is a narrow bar running along the top edge of the screen, displaying some numbers and symbols, with “dwm-5.9″ in the right corner. This bar is known as… or shall we just call it “bar” for now.

Try pressing Alt+B to toggle the bar visibility. The numbers you see are virtual desktops (called tags in dwm) — dwm provides nine of them by default. Try Alt+[Num] to switch between tags. The weird []= symbol you see next to the tags is your current tiling layout. dwm offers three layouts by default — tile ([]=), monocle ([M]) and float (><>).

The “dwm-5.9″ string you see in the far left can actually be changed to show useful information like the current date, time, network status, battery status, etc.

This is a good time to get acquainted with dwm’s keyboard shortcuts. Remember, keyboard shortcuts are of prime importance in tiling WMs, and you should know them as if your life depended on it. You can configure them to your liking, but it helps to get acquainted with a few default ones.

  • Alt+Shift+Enter — Launch xterm
  • Alt+Shift+C — Kill a client (a window, if you must insist)
  • Alt+t — Switch to tile layout
  • Alt+m — Switch to monocle layout
  • Alt+f — Switch to floating layout
  • Alt+b — Show/hide bar
  • Alt+p — Launch dmenu
  • Alt+[num] — Switch to tag [num]
  • Alt+Shift+Q — Quit dwm

dmenu is an application launcher from the author of dwm, following the same minimalist philosophy as dwm. It is a part of the suckless-tools package we installed earlier.

Now we will try out the tiling modes of dwm. First, close any open clients (Alt+Shift+C) and switch to tile mode (Alt+t). Now open xterm using dmenu:, press Alt+pand you should see the bar replaced with something like Figure 2.

dmenu

Figure 2: dmenu

Start typing the name of the app you wish to launch, and once dmenu has narrowed down the search, select it using the arrow keys, and press Enter. Launch xterm this way. It will occupy the entire screen. (See Figure 3 — the number ’1′ has been added by me.)

xterm fullscreen

Figure 3: xterm fullscreen

Open another xterm client (using either dmenu or Alt+Shift+Enter). You will find that the previously opened xterm automatically resizes and moves to make space for this newly opened one.

In Figure 4, Area 1 is called the master area and Area 2 is called the stack area. The master area can hold a single client, while the stack area holds all the remaining ones. Any newly opened client always occupies the master area, and existing clients get pushed into the stack area. Open up a couple of more xterms to see how this works.

Master and stack area

Figure 4: Master and stack area

You can switch focus between clients using Alt+j and Alt+k. Focused clients are denoted by a blue border, while the rest have a grey border. You can move a focused client from the stack area to the master area using Alt+Enter.

Play around with these shortcuts till you get the hang of exactly how the tiling works. Finally, you can change the ratio between the master and stacking areas using Alt+h and Alt+l(Figure 5).

One client in master area, four in stack area, with highly skewed area ratio

Figure 5: One client in master area, four in stack area, with highly skewed area ratio

Now switch to the monocle layout (Alt+m) to have the focused client occupy the entire screen. Note how the []= sign in the bar changes when you switch layouts. This layout is equivalent to maximised windows in floating WMs. Note that the Alt+j, Alt+k and Alt+Enter shortcuts will work in this layout too.

The final layout is the floating kind, which is equivalent to your conventional floating WMs. Move the clients around using Alt+LMB+Drag and resize them using Alt+RMB+Drag. Note that you can switch individual clients into floating mode, without affecting the layout of the rest, by using Alt+Shift+Space. Floating clients always stay above the tiled ones.

Tags in dwm are a more powerful version of virtual desktops in KDE/GNOME, etc. A client can have more than one tag associated with it, and you can view all clients from any number of tags simultaneously. Use Alt+[num] to view all clients with the tag [num] and Alt+Ctrl+[num] to view clients with tag [num] in addition to currently visible clients. Use Alt+Shift+[num] to associate the focused client with tag [num], and Alt+Ctrl+Shift+[num] to associate in addition to current tag associations.

There is still a lot more tweaking left to do before you can use dwm as a full-fledged replacement for Unity. This includes configuring a system tray so you can use the NetworkManager applet under dwm, displaying some meaningful information in the bar instead of the curt “dwm-5.9″. It also includes configuring dwm by editing its source code (have a look at /usr/local/src/dwm-5.9/config.h to get started), and making your GNOME themes and settings carry over to your dwm session (if you open any GNOME apps at this point, they will have an ugly theme and unreadable fonts).

Note: Use nautilus -- no-desktop in dmenu to launch Nautilus, or else it will mess up your dwm session. A default rule in dwm specifies that Firefox should open in Tag 9 by default.

Happy tiling!

Feature image courtesy: Aunt Owwee. Reused under the terms of CC-BY 2.0 License.
  • RAjat Akre

    how to get free linux cd!?

  • Jp Gangwar
  • Jp Gangwar
  • Jp Gangwar
  • Jp Gangwar
  • Schiwi Schiwasinske

    try it at http://www.ubuntuusers.de, they love to help (and they can speak english too ;) )

  • Schiwi Schiwasinske

    try it at http://www.ubuntuusers.de, they love to help (and they can speak english too ;) )

  • Schiwi Schiwasinske

    try it at http://www.ubuntuusers.de, they love to help (and they can speak english too ;) )

  • Jason Steinberger

    obviously you dont know about google yet, that will tell you more than just where to download linux! i highly recomend http://www.google.com you asked 2 hrs ago, but google woulda showed you in like 2 seconds, you would be on lyour way to having it installed!

  • Jason Steinberger

    obviously you dont know about google yet, that will tell you more than just where to download linux! i highly recomend http://www.google.com you asked 2 hrs ago, but google woulda showed you in like 2 seconds, you would be on lyour way to having it installed!

  • Jason Steinberger

    obviously you dont know about google yet, that will tell you more than just where to download linux! i highly recomend http://www.google.com you asked 2 hrs ago, but google woulda showed you in like 2 seconds, you would be on lyour way to having it installed!

  • Jason Steinberger

    obviously you dont know about google yet, that will tell you more than just where to download linux! i highly recomend http://www.google.com you asked 2 hrs ago, but google woulda showed you in like 2 seconds, you would be on lyour way to having it installed!

  • Jason Steinberger

    obviously you dont know about google yet, that will tell you more than just where to download linux! i highly recomend http://www.google.com you asked 2 hrs ago, but google woulda showed you in like 2 seconds, you would be on lyour way to having it installed!

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.