The Gregory Jay Blog



A week with DWM

It's been a week or so since I installed DWM and I am, on the whole, happy with it. In fact, so much so that I take back all the horrible things I said about it last week! I'm seeing now how configurable it is and how useful the patching system, rather than the config system, really is.

It was a rocky start I must admit, not knowing how to configure anything and looking at a list of C files that I couldn't read did, at first, make me feel like the only way I was going to be able to configure DWM was by learning C and essentially coding in the features I wanted. Luckily this was not the case!

Patching DWM

Window managers I have used in the past were configured by making changes to a config file of one type or another and reloading the WM. DWM doesn't work this way. There is a config file but there is not a huge amount of configuration possible with the config file alone. Keybinds, fonts, colours and workspace/tag names can be changed here but not much of anything else. How then do we change the behaviour of the WM? This is where patching comes in! Want to change to the next workspace/tag? You need a patch for that. Want to have different colours for the bar and window border? Yoe need a patch for that. Hide the unused tag? Patch. Cycle through your layouts? Patch. Want a scratchpad? Patch.

At first it does seem inconvieniant to have to patch in every little feature you want. However, in reality patching DWM is, in threory at least, quick and easy - download the patch and install it with one command. There is some artistic beauty in this methodology. Why have features you don't need? In DWM you are getting the bare bones of a window manager, a stripped down version that's snappy and ready to be molded to your specificiation. I don't want to see my unused tags because I'm used to that feature from i3 but there is no need to build this in to DWM when most people wont want it. Most people will want to cycle through the layout options but still, there is no reason to build this into DWM when some people wont want it. The bottom line is if you want a feature - patch it in!

So here is what I have patched in:

Tag Cycling

This is a the only way I move from tag to tag. Instead of hitting mod+5 to go to tag 5, I use mod+h or mod+l to cycle back or forewards through my tags till I get to tag 5. This does seem like more key presses but it does have some advantages. I don't need to reach up to the number row, my fingers stay on the middle row and the furthest I ever have to travel is 4 tags (say from tag 1-5) which is four key presses. The other advantage and the real reason I like this setup is that I can have another funtion for my mod+numbers - opening a program on that tag.

I like to have my browser on tag 2, my image editing software (darktable) on tag 3, my file browser on tag 4 etc. I've had my window manager set up this way for years and really wanted to recreate it on DWM. I just needed to add a keybind for mod+2 to my config to open my browser and DWM would go to tag 2 and open the browser. I do this for all my most commonly used programs.

Title Color

This is a purely cosmetic patch. DWM's standard behaviour is to outline the active window in the same colour as the background of the active tag and background of the window title. The title color patch allows you to change each of these individually. I wanted the whole of my bar to be black, which I could do but it also made the active window border black, that made it difficult to see which window was active when I had multiple open windows. Now I have my all black bar with a purple border around my active window just as I wanted it.

Hide Vacant Tags

This is really just something I am used to having from i3 but I do think it's useful. By default DWM shows all the tags in the panel at the top, this patch only shows them if they have an open window within them.

Configuring

With all the patches done I only had a little configuring left to do. Most of this configuring was fairly painless, in fact I don't think I had any real problems with this. It really just came down to theming, the panel and keybindings.

Yes, theming not 'ricing,' I don't know why but the term seems a little too much like the tech equivalent of 'let me take a selfie with my food before I eat it.' Everyone configures they're system to some extent but people only use the word when they are doing it to show off, or at least that's how it seems. I have lived in China for the last 13 years and so most of the social media world has passed me by. I have no twitter or snapchat, discord remains a mystery to me. I have used facebook in the past but I never had it installed on my phone (I still don't see why anyone would need it on their phone) and so I have never felt the urge to take selfies or pictures of my food. When I see something interesting I look at it unlike everyone else who pull their phones out first and take pictures of it (I used to not understand when they would get the chance to sit down and look at all these pictures, then I realised that the pictures they take are not for themselves to look at or to remember the moment, no, they are to put up on instagram to garner likes for God know what.) oops I'm ranting.

Anyone familiar with window managers will have replaced they're workspaces or tags with awesome font icons, and that's what I did. Instead of using icons like  or  for tags where you usually open the file manager or browser, I decided to just use silly icons like bacon  , a dragon  , and a ghost  , because why not? Then I set the font colours to purple and green, the backgrounds to black and the borders to purple. I found a nice purple and black wallpaper to match. Theme done!

The panel

I chose dwmblocks as my panel, mostly on the recommendation of Luke Smith. It has some advantages over the default panel that comes with DWM. You can set the reload frequency of each individual module and send signals to it to force it to update a certain module. Neither of these are possible with the default panel. Obviously your cpd usuage reloaded constantly while it would be a waste to update the package updates, the date or in my case the pm2.5 levels for the city I live (the data itself is updated every hour so I reload that module ever 30 mins or so) that frequently. Sending a signal is useful to force the module to update for things like, displaying the volume, it only updates when you change the volume and give it the signal rather than it checking every second or somesuch frequency.

Finally the keybindings

The ability to bind keys for my most frequently used tasks is one of the main reasons I switched to a window manager from a full desktp enviroment in the first place. Not that you can't bind keys in a desktop enviroment, of course you could, but WMs are built with binding keys in mind. I think that once you are used to having keybindings most of the icons and menus and other ui elements just seem redundant and in the way. I really needed keybindings for the following functions:

  • Changing tags and opening programs
  • takign screenshots
  • Running scripts for brightness, volume, vpn, password manager, browser bookmarks, opening file/web browsers, shutdown, dmenu, youtube-dl, music search
  • Moving windows etc
  • Changing tags and moving windows is already setup in the config and so making small changes to them is fairly easy. I did have to go online to check how to open applications and run scripts though, not intuitive but once you know, easy enough. The last buttons I managed to get working were my brightness buttons which I was especially pleased about as I had had full brightness shining at me for about 2 weeks straight at that point.

    Now that everything is setup more or less the way I want it, I am really happy with DWM and will probably install it on my main machine too, eventually

    Feel free to take a look at my github here to see my config.h file.

    Greg is a true Sinophile, fluent in Chinese and proficient in Tibetan he is a homeschooling Dad that also consults on the side. You'll often find him cigar in mouth, book in hand, waiting for someone to finish their work or for the coffee to brew.