Patching DWM

Patching DWM is incredibly finicky if you choose to use auto-patching programs. Manual patching is the way to go!

I'm going to be applying this patch here: focusonnetactive.

Let's first acquire the patch itself. I'll save it to a patches directory where my DWM source code is located.

The deal with patching manually is being able to read diff files. It's not too difficult, but any formatting is nice to have. I use bat, and this gives me a good idea of what needs to be done.

a screenshot displaying the diff file for the relevant patch

The stuff in green is what we need to add. The stuff in red is what we need to remove. The file in which this needs to be done is also specified, in this case, dwm.c.

If you look closely, they've specified at which line things need to be added. In the first case, it's around line 514. Go there, then see what matches whatever they've specified.

a screenshot showing the area specified in our configuration file by the diff file

It's not an exact match, but we can see the region we need to change is just below it. I've added the new line there.

Rinse and repeat for the rest.

When you're done, simply rebuild your dwm.c again. It'll tell you if you have any errors. If you do, they'll likely be minor syntax errors. Read through the output, it's pretty clear.

a screenshot displaying compilation errors
Unisigned integer wow

You might start to get an idea as to why auto-patching programs tend to get really finicky after a while, mostly after you've applied patches. They just insert the code at whatever line is specified in the diff file, which may break syntax or logic, that sort of thing. Auto-patching works fine for the first few patches, but especially on excessively patched DWM configurations, they tend to just not work.

Anyway, that's the first patch I've applied since I went back to DWM. It's been about a month.

This article was written on 20/06/2024. If you have any thoughts, feel free to send me an email with them. Have a nice day!