 Today, I'm going to make a video on a topic that I have made videos on in the past and that is how to patch the suckless software. Things like DWM, D-Menu, the surf browser, the ST terminal, things like that. And the reason I'm going to make this video today is because those videos in the past that I did about how to patch some of the suckless software, those are old videos. A lot of people weren't around when I made those videos. So I'm still getting viewer questions about, hey, how do I patch DWM? How do I patch ST? Or I tried to do the automatic patching and it fails. How do I go about manually patching because I can't figure out how to read the diff files? Things like that. So one of the things for me is I needed to update my suckless builds anyway because some of these programs have seen updates since the last time I patched these things and built them myself. D-Menu, for example, has had two new releases in the last year and I don't think I've updated my personal build of D-Menu in that time period. So for purposes of this video today, I'm going to go grab the source code for D-Menu. I'm going to grab a bunch of patches and we're going to patch D-Menu. So the first thing we need to do is go to suckless.org and grab the source code for D-Menu. Now at the top of suckless.org's webpage you have tabs for DWM, ST, SERF, and then tools here is where you will find D-Menu. So go to tools, click on D-Menu and download the latest version of D-Menu which is 5.0 and just download that down. It's going to be, I think, a TAR-GZ archive and once you have the source code for D-Menu, figure out what patches you want to apply to it. And for purposes of this video, I'm going to apply a ton of patches to D-Menu on camera. Why? It's because when you apply a ton of patches, sometimes they're going to fail. The automatic patching is going to fail on a lot of these. I know that. You can't heavily patch these things and not have some failures along the way and I want some failures so I can show you guys how to do the manual patching. So if I'm going to go grab some patches, I'm going to grab the border patch to give me a border around the window. I'm going to grab the case and sensitive patch to search case and sensitivity. Is that a word? I don't think I pronounced that right. I'm going to grab the center patch which allows us to center D-Menu in the middle of the screen if we want it. I want fuzzy highlighting too so we get the letters colored when we're fuzzy matching. Of course to do fuzzy highlight, I also need the fuzzy match patch. I'm going to do the grid patch too because that gives us columns. If we want columns, highlight, I like the highlight patch. I've used it before. I'm going to need the line height patch. That's one that almost everybody applies because it allows you to exactly specify the height of the D-Menu. That way you don't have weird things like D-Menu not completely covering up the panel that you're using in your tiling window manager for example. I'm also going to grab the more color patch just to give us some more color options. Hey why not? I typically don't use the mouse with D-Menu but there's no reason not to add it. I'm also going to grab the numbers patch so we have a number out to the side of our D-Menu. It'll let us know we've got four matches of a possible 51. I'm going to go ahead and grab the vert full patch so this allows us to what it does is instead of having that weird invention that happens in D-Menu especially on a vertical list where you have the prompt and then everything else kind of off to the side of it indented, it puts them all in a proper row like they should be. So I'm going to do the vert full patch and then I think that's about it and maybe I'll add one or two more. Let me go ahead and download these patches and by the way to download the patches all you need is the diff file. So all these files that end in .diff make sure you grab the latest one because some of these may have multiple patches like if I click on the center patch here there's two patches and I'm assuming the oldest one is at the bottom of the list because it's dated January of 2020. So I'm going to assume that's probably the latest diff and what I'm going to do is I'm going to right click on that diff here in Firefox or whatever browser right click on it and then save link as and just save that to your downloads folder. I'm going to grab about 10 or 12 of these diffs. So let me switch to the desktop here and let me open up a terminal and let me zoom in a little bit so you guys can see what's going on and I'm going to CD into this directory here and I called it's dmenu-build here and if I do an LS this is where I placed all the source code for dmenu so that targz I extracted it into this directory that I named dmenu-build and then I also threw all the diffs in this directory here also just for convenient sake having all in the same directory that way I can do an LS and remember exactly what patches I'm trying to apply here and I'm going to go in order of just alphabetical order here and one at a time I'm just going to try to apply the automatic patching and many of these are pretty simple patches so I imagine the first few probably will go okay the automatic patching will probably work just fine as the more patches we apply though the more and more the automatic patching will just no longer work and then I'm going to have to manually patch these things so to do the automatic patching you need to run the command patch and then dash and I'm going to do p1 just to give it a number here and then the patch I'm going to do let's do the border patch so let's run that and the automatic patching succeeded just fine you see number one succeeded if we would have had a failure then in capital letters the word failed would have appeared so that one worked just fine so let's go ahead and try the next one let's see if case insensitive works and the automatic patching for that works as well let's go to the next one the center patch and the center patch is our first failure you see honk five failed at 732 and it tells us one out of five honks failed and it's saving the failures in a file called dmenu.c.rej for I guess rejection so if I do a ls here you will see I have dmenu.c.rej and that file will tell us hey here's the patches you tried to apply and here's the ones that were rejected and that's the ones we're going to have to manually do something with so if I open in vm in my case but you can open this in any text editor you want to use it doesn't matter but this is what a diff file looks like it tells you hey this was the patch these with the plus symbols we were trying to add these lines to that file doing the automatic patching but for some reason we weren't able to do that so now I need to manually go add these two lines to the file dmenu.c you can see that the diff here was looking for something at line 732 and it didn't find what it was looking for that's why it couldn't apply the patch because the more patches you apply the more the line numbers get way out of whack for for the automatic patching so for some reason it just couldn't grab that so what I'm going to do is I'm going to open up a second terminal here and I'm going to zoom in in this terminal and let me cd back into the dmenu-build directory and this time I'm going to open up dmenu.c because that is the file and we need to go to line 732 so here in vmfi type 732 capital G I will go to that line and you can see that that is the right area to be in and in the diff file the lines with the pluses are what we need to add it also gives you the line right before it and the line right after it so the line right before it is dash f that flag grabs keyboard before reading standard in which is this right here dash f grabs keyboard before standard in so let me create a new line here because this empty line is where these two lines here need to go so let me do a 2y y to yank those two lines and if I go back over here and to this instance of them and do a paste you know I just pasted those although I don't need the plus symbols so if I just highlight the x so if I just highlight the plus symbols and hit x on the keyboard it'll delete that plus let me do the same to that and then let me dd to get rid of the empty line that was left there now if I do a right and quit we're done with that patch you know that patch is fine so let me quit out of that so let me swap these windows here so this command I'm about to type my head will not be in the way so let me get back to the last patch here that we tried to apply which was the center patch and let's see if we can do fuzzy highlight and the fuzzy highlighting patch succeeded with the automatic patching very cool let's see if the fuzzy match patch succeeds with the automatic patching it does not it failed and it failed we need to add something to config dot def dot h and we need to edit something in d menu dot c again and it created two rejection files config dot def dot h dot r e j and d menu dot c dot r e j and those are the files we need to read to figure out what went wrong I hope that makes sense so over here I'm going to open up in vim config dot def dot h dot r e j and we needed to add it looks like just one line this line here so in the other terminal here I'm going to do vim and I'm going to open up config dot def dot h the actual file not the rejection file and I'm going to look for somewhere around line two look for line one that says static int top bar equals one so we've got that and then on the next line is what we need to add here so let me do a yy to yank that line and then over here I'm going to do a paste and then let me get rid of the plus symbol you're right and quit so that patch is taken care of let me quit out of that and then the other rejection file let's do d menu dot c dot r e j and just one line again that looks like the same line from before so I'm not sure if I actually need to do anything line seven eighty nine so let me do seven eight nine capital g to go to that line and I guess the patch failed because it was looking for this in the wrong spot because seven eighty nine was not where what it was looking for is actually at I may actually have to do a search it's looking for grabs keyboard so let me do a slash I'm going to type grabs keyboard okay there we are so there's that line and then we need to add this one over here let me get rid of the plus symbol be right and quit and then let me just quit out of the rej file all right and that should take care of that one so I have tried to do about a half dozen of these 12 or so patches and like four of them the automatic patching worked two of them the automatic patching didn't work but I was able to manually patch it just by reading that def file now I know some of this is a little confusing because sometimes you get some rejections and you there's several pieces of code you have to plug in sometimes in multiple files as a matter of fact that last patch that I had to do I had to patch two different files so sometimes you may have to patch two three four or more files to make these patches work it can be tedious the manual patching can be tedious I'm not going to lie but that's that's the way it has to be done all you have to do is read that def file and every line that has a plus you need to add it to the file every line that has a minus which we haven't seen yet but if it had a minus in front of it you need to go find those lines and delete those lines from the file so let me get back over here into the terminal here and run a ls now just for sake of completeness so you guys don't have to sit here and watch me do all 12 patches on camera I'm going to stop right now on camera at number six or so and let's do a pseudo make install to see if I actually patch these things correctly and if I did everything should work if I didn't I'm getting errors now the good thing about these errors is it typically tells you exactly how you messed up it says line 868 and dmenu.c and tells us the error to write around that line with the grabs keyboard you know they had a couple of patches that involved that line and you know that second patch I was actually surprised that that second patch filled and it had something to do with that line so I bet the very first patch that involved that line I probably messed that patch up I could probably read the def file again and just make sure that you know I put everything in the right spot I'm trying to remember what that first patch was I think it was the center patch so what I'm going to do is I'm actually going to open up that dmenu center diff okay let's open up that diff and let me go ahead and open up another terminal cd into dmenu-build here do an ls and I'm going to open up dmenu.c because for sure that's the file that's messed up because the error message told us that and I'm going to go ahead and go to line 868 I believe was the line yeah grabs keyboard so let's read the diff file let's get to the section where it talks about the line to add around grabs keyboard here it is toward the bottom of the diff file and should go behind that line actually you know what it's not behind this is two lines I actually thought the two lines with the plus symbols needed to be pasted after that line actually needs to be pasted after this line I actually thought that was still a continuation of that line fast equals one so fast equals one here is not in the correct spot so let me get rid of that and let me put it back in the correct spot which is right here under the grabs keyboard before reading standard out let's paste that let me write and quit I'm just going to get out of that and then the diff file I just need to quit out of and now let me do that pseudo make install still complaining about dmenu.c so once again let me go back into the center diff because I think that's yeah because the dash c flag and it involves the center diff I messed up the center diff somehow all right and these lines here you know what I think I made the same mistake twice it's what it looks like let me do grabs keyboard let's do a search you know what I bet this fast equals one I bet it was in behind this dash capital F flag even though that's not really what the file is telling me I bet I messed that up I bet I ended up deleting some lines or moving some lines around let me write and quit and do a pseudo make install just to see if that works and it builds correctly so yeah so I went through the automatic patches and clearly I messed some stuff up along the way but you know that's I'm going to leave all of this on camera even though I completely butchered the automatic patching I'm glad I messed this up that way I had to look at the error message in the terminal to figure out what file is messed up and then I go back and read the original diffs right and figure out okay did I plug in everything correctly which clearly I didn't and and you guys now that I've made those mistakes hopefully it helps you when you guys make those same mistakes let me cd into my actual finished d menu build so it's actually called d menu dash distro tube if I do it ls you see I have all those patches and this is the finished product because I didn't want to make an hour long video you guys seeing me run through you know 12 or so different patches many of them having to manually patch it can be a long and tedious and kind of repetitive video but once you have all the patching done if you do a pseudo make install it makes very quickly see no errors and if you guys wanted to see my d menu in action there is d menu just d menu underscore run now if you wanted to see what some of these patches actually were so we had the border patch the center patch the fuzzy highlight patch so let me do d menu underscore run I'm going to give it some flags so this is an example I'm going to do d menu underscore run space dash c for put in the center of the screen I don't want it at the top or the bottom where d menu typically is placed I want it as a window in the center of the screen then I gave it this flag from one of the patches that I added dash bw for border width I want it to have a border width of two and then space dash l for lines how many lines I want at 20 lines so this is vertical lines because again we're going to be placed in the center of the screen so I need a vertical line count and then finally we did the grid patch and it's going to be dash g for grid and it specifies the number of columns in the grid we're going to do four in this so there you go we also have the numbers patch we have a lot of different colors patch because we did the fuzzy matching and the fuzzy highlight and the more color patch so if I start doing al a for alacrity maybe if I was searching but you see the fuzzy so we're getting a lot of fuzzy matching and then the fuzzy matching has some coloring you know it changes the background and the foreground for the letters that it's doing the fuzzy match on also let me rerun that command you notice that when I move the cursor here obviously the selection is highlighted but the adjacent selections are also a different color and that was part of the more colors patch I believe now is that some cool functionality that really needed to be here probably not but I think it's cool also the vert full patch that is what makes the prompt and then the columns all are up underneath the prompt instead of being way off to the side in a weird indention which is the default behavior for d menu it looks weird so that's why I applied that vert full patch you guys can go get my build of d menu from my get lab if you guys go to getlab.com slash dwt1 and I have like 12 15 different repositories on my get lab go to d menu dash distro tube and I will go ahead and push the latest build with all these patches because I do think it's kind of a cool build I want to share it with you guys so let me go ahead and do a get push and then you guys can go ahead and grab that those of you that are running arch or arch based distros you can actually grab a d menu dash distro tube from the a u r if you have yay run a yay d menu dash distro tube dash get now before I go I need to think a few special people I need to thank Michael Gabe Caribbean Mitchell Devin Fran arch 55 30 a commie chuck laudio dunny dillon george rey kelev devils loose paul scott and willy they are the producers of the show they are my highest tier patrons over on patreon without these guys this episode about patching the suckless software wouldn't have been possible the show is also brought to you by each and every one of these ladies and gentlemen as well these are all my supporters over on patreon without these guys this episode you just watched wouldn't have been possible because this channel is supported by you guys the community if you'd like to support my work check me out on patreon all right guys peace