Going fast with DWM

If there was any justice in this world, there would be two cars parked in my driveway. One would be a 1977 Ferrari 308 GTS. The other would be a midnight blue BMW M3 convertible with all the amenities. I'd want the leather seats and power everything. When I'm in the BMW, I don't want to have to roll the windows down; I want to push a button and have a leprechaun come out and roll them down for me. I want to point the car in the general direction of where I want to go and have it drive me there. That's right, sometimes a guy just wants to be pampered.

Then there are those times when I just want to go fast, fast enough that I wouldn't have time to roll the window down and the leprechaun would be too afraid to unbuckle his seatbelt. In the Ferrari, I'm sure I'd feel every pebble in the road and I'd spend most of my weekends working on the car trying to coax out every last bit of horsepower. When I'm driving, I want to have to think about if I should down-shift from 3rd to 2nd, or maybe even down to 1st. And I want to know the car inside and out.

Well, if you're not geeking out over all this car talk, you're probably wondering what it has to do with Linux. In my day-to-day work, I use the K Desktop Environment (KDE). You could think of KDE as being like the BMW I mentioned earlier. As a user, you practically never have to get under the hood. And it seems that there is a button or a dialog box to perform just about any function or configuration change that you could imagine. If you don't know the name of the program you want to run, there's usually an icon or menu item that you can click on. Like the BMW, KDE isn't known for being fast or lightweight, but it is very comfortable.

Weighing in at a mere 2140 lines of C code, the Dynamic Window Manager, (DWM) certainly qualifies as lightweight. There aren't any menus, and no icons. You can't use a dialog box to change the screen colors, either. You literally have to get under the hood to make configuration changes, which we'll talk about shortly. Most of the time, you won't even use the mouse. Once you've learned how to “drive” DWM, you can really go fast in it.

Likewise, installing DWM couldn't be easier. Simply download the tarball from dwm.suckless.org and extract the contents. Then run make in the resulting directory. The result is a single executable, dwm. If you then run make install, make will install a man page and install the dwm executable in /usr/local. For testing, I simply ran dwm from my home directory.

I have to admit that my first impression of DWM was less than stellar. After I killed the KDE environment I was running and launched DWM I was almost immediately confronted by a simple gray screen with some numbers across the top. Without a menu, I was a little disoriented. So I decided to go back and read the fine manual.

After reading the manual and the tutorial on DWM's website, I discovered that would bring up an x-terminal. Finally, something I could relate to! As I started more x-terminals, DWM pushed them onto a stack along the right-hand side of the screen. With just a few quick keystrokes, I was able to flip through the “stacked” windows and bring them up to the top. After a couple of minutes, I could see that it would be very easy to train my fingers to navigate between several windows without ever picking up the mouse.

DWM lays out program windows according to one of two modes, tiled, floating, and monocle. The user can switch between these modes with , , and , respectively. Tiled mode is the default and behaves as I described earlier. In floating mode, windows may be dragged around the screen with the mouse and behave much like they do in other windowing environments. In monocle mode, the main window takes up the entire screen and can't be manipulated. To me, this seems like a very simple way to setup a kiosk machine. Simply put DWM in monocle mode and remove the key sequences to put it in a different mode.

Windows in DWM are organized by assigning one or more tags to them. Then the user can chose which tags to display in each virtual screen. This mechanism is actually more flexible than what I enjoy with KDE, since it allows a given window to appear in any number of virtual screens. I'm not completely comfortable with this mechanism, but I think I'll like it once I am.

When I first read that configuration changes to DWM were made by modifying the source and recompiling, I couldn't believe what I was reading, but it's not nearly as bad as it sounds. The source code is contained in two files: dwm.c, which you shouldn't have to modify, and config.h which is where you make your changes. By changing config.h you can change the color scheme, tag names, magic keyboard and mouse assignments, and more. The config.h file is only 100 lines of fairly well commented code, so let's take a quick look.

Starting on line 5, we have appearance settings. For example, we can set the color of the window border by modifying this statement:

static const char normbordercolor[] = "#cccccc";

We can even change the number of pixels used to frame the windows, which defaults to 1, and where the status bar appears.

We can predefine the names of the tags we want to use to organize our windows on line 16. By default, the tag names are simply the numbers 1 through 9.

static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

We could redefine these to be “email”, “reference”, “work”, “play”, or whatever makes sense to us.

The next section of the config.h file is one that I think could use a few more comments. This is the rules section. The default looks like this:

static const Rule rules[] = {
        /* class      instance    title       tags mask     isfloating   monitor */
        { "Gimp",     NULL,       NULL,       0,            True,        -1 },
        { "Firefox",  NULL,       NULL,       1 << 8,       False,       -1 },

From this, I'm gleaning that DWM can handle different applications differently, but the documentation is a bit lacking here.

Next, we see some layout configuration options, but I'm going to skip ahead to the keyboard and mouse command sections, from which, I've pulled out a few highlights.

/* commands */ 
static const char *termcmd[]  = { "uxterm", NULL };                                                                                                             

Here we see that the developers have described what's involved in launching the uxterm program. There are other commands defined, and the user is certainly able to expand this list as they wish. These definitions are use in the next section, where we assign functions to keystrokes.

In this section, we can determine what happens when we press various key combinations. The MODKEY constant has been defined elsewhere to be the Alt key. Take a look:

static Key keys[] = {
/* modifier            key          function     argument*/      
{ MODKEY|ShiftMask,    XK_Return,   spawn,       {.v = termcmd } },                                                                                        
{ MODKEY,              XK_t,        setlayout,   {.v =&layouts[0]} },
{ MODKEY,              XK_f,        setlayout,   {.v = &layouts[1]} },
{ MODKEY,              XK_m,        setlayout,   {.v = &layouts[2]} },

The first entry simply says that when the user presses the key sequence, DWM should spawn an x-terminal. From here, it's pretty easy to see how one might define a hot-key sequence to launch our favorite web browser. Finally, I've shown how the window layout (tiled, floating, and monocle) mode key sequences are defined. If we wanted to create a kiosk machine, we'd simply remove the other options at this point, for example.

The mouse sequences are defined similarly.

There is a surprising amount of configuration to be found in DWM's config.h file. But going back to the automobile analogy, I just wanted to pop the hood and show you where the spark plugs are and how to check the oil.

I think that in the end, if you want a full-featured windows manager with all the amenities, DWM probably isn't for you. On the other hand, if you want something light and fast, and like to tinker, I would definitely check out DWM.


Mike Diehl is a freelance Computer Nerd specializing in Linux administration, programing, and VoIP. Mike lives in Albuquerque, NM. with his wife and 3 sons. He can be reached at mdiehl@diehlnet.com


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

dwm - a nice windowmanager

Andreas Wittmann's picture

dwm is a great windowmanager. I've tried many other wm's but dwm is now my favourite one. Easy to learn, expandable, fast and very tiny. xmonad has too many depencies, kde and gnome won't work well on my small system. Another good one are fvwm and icewm. stumpwm is also a great wm but was too slow and buggy the last time i've tried it.

A good window-manager should stay in the background. There is no need to look at fancy icons, especially for user's which use their computer to get job's done.

A nice article, thanks!

I think it would be more

Anonymous's picture

I think it would be more beneficial to compare the functionality of KDE's window manager (KWin) to dwm, rather than the entire desktop environment. I don't think anyone who uses alot of programs that use the WIMP paradigm are likely to switch to a tiling window manager; such programs are broken in that they don't provide very useful keybindings (or any) and make stupid assumptions about controlling their own window geometry. That being said, dwm (and most other tiling window managers) still offer the choice of doing things the WIMP way through the implementation of a "floating" layout. If, however, one finds themselves using lots of keyboard-centric applications, then using a tiling window manager like dwm can boost productivity (and sanity). As a poster above already mentioned, there is also wmii, the big brother of dwm which some might view as more user friendly (e.g., doesn't require recompilation/reinstallation for configuration changes).

What tiling window managers are really missing is the ability to keep state across sessions. This has been discussed before, and the given solution has been to not kill the X session, which implies not rebooting. This is the one of the major caveats that tiling window managers are responsible for. Another one in the case of dwm is requiring the editing of C structure definitions for configuration. Yes, adding a configuration parser would add a lot of code, but it could become a separate small tool used for transforming non-programmer readable/writeable options into what is necessary.

Never use car analogies

Anonymous's picture

You'll attract all kind of idiots talking about cars...

Dreadful review

Rory C-L's picture

The car analogy is a very poor one for anyone looking for an interesting window manager. dwm isn't interesting for its speed or road holding abilities.

The main reasons I like dwm and have been using a now rather out-dated version of it for about 3 years is that it allows me to work effectively in a largely terminal-oriented and keyboard-controlled environment. If you do most of your work in a textual environment, don't mind editing /etc/network/interfaces by hand and are more likely to be running vim-nox, cmus, and irssi than their more graphical counterparts, you may find that dwm is worth trying out for a few weeks at least.

dwm and the other suckless software also have a strong aesthetic sense which have spawned a host of emulators, many of them very innovative in their own right, such as awesome and xmonad. Perhaps this is what the reviewer was grasping at: the Ferrari he mentions is arguably a finer car than the BMW, although those who love dialog boxes might not understand that.

Not all light wm are equals

frankie's picture

Many tiled wms have problems under at least a couple of regards:

  • xrandr support (e.g. resolution changes on-fly)
  • xinerama-like support (i.e. dual/multiple monitors configuration)

At my knowledge the only decent support is available with awesome and xmonad. Maybe i3, but I'm not sure. So be sure to choose the right one :-)

Are you serious?

Chuck's picture

"Like the BMW, KDE isn't known for being fast or lightweight, but it is very comfortable.". Have you ever even driven in an M3? The M3 can reach 60 MPH in 4.1 seconds while the Ferrari takes 6.9 seconds ( Even my 328xi can get to 60 in 6.1 ). Also, mentioning how the M3 has buttons to roll down your windows isn't very impressive seeing as how even KIAs come equipped with such amenities. If you really want to talk about luxuries how bout using a 7 series and mention it's "Night Vision with Pedestrian Detection" option. I don't think we'll be seeing any KIAs with that anytime soon. However, even a big, fat 7 series is faster than that Ferrari... anyway DWM sounds interesting, I'll have to give it a try.

My mom's 1977 Ferrari 308

Skike's picture

My mom's 1977 Ferrari 308 sucks compared to my 2001 BWM 330Ci. Anyway, I'm not going to try DWM now, because a guy who disses the M3 and likes KDE told me to. I already prefer openbox or fluxbox because they are always fast, and I don't need to keep switching back and forth. If you spend enough time configuring openbox of fluxbox, you can make it nicer than some stupid KDE configuration. Add some programs like wbar, tint2, and xcompmgr, and you have yourself a well rounded desktop. KDE is great for people who want the closest possible experience to M$ Windows. If someone held a gun to my head and said I had to choose a desktop environment, I'd take Gnome every time. But now I digress. You talk about not having to go under the hood? I go under the hood of my BMW all the time. Do a little reading and you will know everything about the car. Only rich nerds like Chuck (see original comment) go to the dealer and pay an arm and a leg for routine maintenance. It's not as complicated as it looks. Same with linux, don't be afraid to get your hands dirty. If you are afraid of breaking something, try it with a virtual machine in VirtualBox instead. And your other comment about sometimes a guy just wants to be pampered? That's what women are for. So take a little time, get rid of that KDE, and set yourself up a more functional window manager. When you are done with that, do some research and find a better dream car, and then go out and get a woman.


Oh a Linux geek who's

Anonymous's picture

Oh a Linux geek who's actually rich. Surprise.

Thank you very much, exactly

Anonymous's picture

Thank you very much, exactly what I was going to say... BMW M3 as the 'being pampered' solution... no comment.

DWM is probably Awesome, almost as much as XMonad.

Also have a look at

Anonymous's picture

Also have a look at wmii


It's from the same developer, but has a little more features like scriptability and a 9p filesystem interface.


Treah's picture

Icewm is also an excellent choice if your looking for speed. Tho it was kinda panned off being for people coming from windows 95 and 98. I use icewm along with ROX-Filer to give me just about everything I want out of a windows manager without any of the bloat. Tho I will try this one out and see if it grows on me, so far most tiling windows managers have gone into my forgotten bin in /usr/local :)


Anonymous's picture

Are you offended? GOOD NOW SHUT UP!!!

More "niche" software

Thayer Williams's picture

Great introduction to what has proved to be a fantastic window manager. As a dwm user of more than two years (even my wife loves it now), I find it difficult and cumbersome to use mainstream floating/stacking window managers.

It's nice to see dwm finally get some mainstream exposure and I would love to see more articles of this nature in general; vifm, tmux, and rxvt-unicode come to mind.


If there was any justice in

Kyle's picture

If there was any justice in this world, people wouldn't be hungry...

Not trying to spark a political debate, but the first few lines of your article made me quit reading it.

Hey Kyle

Anonymous's picture

Fuck off.

You're wrong, Kyle

Moschops's picture

Some people deserve to be hungry, and justice would make it so. Your statement is simply wrong.

other "niche" wms

B's picture

I would also mention xmonad and awesome wm. I only played a little bit with xmonad, it is very interesting as it is programmed in Haskell, not C. I've used awesome wm more extensively, and I can say that tagging (also present in awesome) is much more powerful than conventional virtual desktops. It is also easy to configure using Lua.

I'd like to see more exotic wms presented here, I want to try dwm after reading about it.

yay no crisco

Anonymous's picture

Very cool, thanks! Nice to know that not everyone in Linuxland is into Crisco :)

If you like the way dwm works

mt66's picture

If you like the way dwm works and empower you, try i3 http://i3.zekjur.net.
In debian simply do: apt-get install i3-wm
i3, dmenu and some configuration makes a really powerful combination.

I'ts nice to see articles over non conventional window managers.


There is no justice

David Lane's picture

And I would have a McLaren instead of the M3.

Thanks for the tips.

David Lane, KG4GIY is a member of Linux Journal's Editorial Advisory Panel and the Control Op for Linux Journal's Virtual Ham Shack