# How to patch dwm?



## lnrt (Oct 9, 2014)

How can I apply custom patches to DWM when using portmaster? I know of the DWM_CONF knob to specify a custom configuration file, but I also want to apply my own patches.


----------



## alivance (Oct 11, 2014)

You can find more info here:

https://www.freebsd.org/doc/en/books/po ... patch.html

If you don't want to waste a lot of time, you can do it the bad way, like I do:

In the work directory there is a file called .stage_done.packagename._usr_local, if you delete that and execute `make reinstall` the package will get rebuilt (and installed) with the modifications you made to the source code.


----------



## scottro (Nov 8, 2014)

For what it's worth, here's what I did to eventually apply the moveresize patch: http://dwm.suckless.org/patches/moveresize.

As mentioned in the link given by alivance once you've created your patch, you can put it in <portname>/files.  So first I created a ~/dwm/config.h file with the moveresize keyboard shortcuts included.  It's not something I use very often, so I stuck with the patch creator's suggestions.  I then, within the port directory, ran `make DWM_CONFIG=/home/scottro/dwm/config.h extract`.  I then edited dwm.c in work/dwm-6.0/.

As I mention on my own page about DWM, http://srobb.net/dwm.html, I had to add a 
	
	



```
static void moveresize(const Arg *arg);
```
 line in with the other static declarations. (Otherwise, when I tried to run `make install clean` I would be getting errors about the moveresize entries in my custom config.h.)

Once I did the edits, I could then run `make install clean` without a problem  Note that I specify the DWM_CONF part while doing  the extract part, not during the install part.

At any rate, once I did this, I made a file by copying dwm.c to dwm.c.orig, and ran `diff -uNr dwm.c.orig dwm.c > patch-dwm.c`. I then put my newly created patch in the /usr/ports/x11-wm/dwm/files section.  Once that was done, I tested it by doing `make clean` and reinstalling with `make DWM_CONF=/home/scottro/dwm/config.h install clean` and when done, I had a working x11-wm/dwm/ with the moveresize patch included.

TL;DR
`make extract`
Edit the files you want to patch, create your patch, put it in /usr/ports/x11-wm/dwm/files/ with a name like patch-<name-of-file> and then do your installation as you would normally, either with Portmaster or `make install`.


----------

