jasonwryan.com

Miscellaneous ephemera…

Patching dwm with pertag and bstack

Over the last several months I have been using dwm as my window manager on two Arch Linux machines: my EeePC 901 and an old Dell at work.

There is a lot to like about dwm, but the most attractive qualities for me are the fact that it is under 2000 SLOC and is very configurable.

The most recent version, 5.7.2, included some changes that meant that some of the patches wouldn’t play nicely together anymore; trying to combine any of the layout patches with pertag would result in the code failing to compile.

Fortunately, there is a fix described on the mailing list. Essentially, it involves manually applying the patch to the source code.

Start with a vanilla version of the code. Move to the source directory and apply the pertag patch:

1
cd $BUILD/dwm/src/dwm-5.7.2/ patch -p1 < dwm-5.7.2-pertag.diff

Then manually add the bstack (or any of the other layout patches) to dwm.c:

Include the bstack declaring function with the others, beginning line 153. I inserted it alphabetically…

1
2
3
4
static void attachstack(Client *c);
static void bstack(Monitor *m);
static void buttonpress(XEvent *e);

And then, after the #include “config.h” declaration at 275, add in the rest of the patch. For consistency’s sake, I included it at line 415:

1
2
3
4
5
6
7
void bstack(Monitor *m) {
  int x, y, h, w, mh;
  unsigned int i, n;
  Client *c; for(n = 0, c = nexttiled(m-&gt;clients); c; c = nexttiled(c-&gt;next), n++);
  if(n == 0)
return;

Add you keybindings into your header file (config.h) and recompile:

1
makepkg -efi

Done.

The only fly in the ointment is that, for me anyway, I have been unable to get any of the other layout patches to work with this setup; either by regular patching or using the above method. YMMV.

Update

So I was wrong: you can get pertag to work with all the other patches, and it is not that difficult

Comments