DWM fibonnaci patch

go back / p4p1


Created on tue. 16 April 2020



I have been using dwm for about a month, enjoying the Fibonacci mode and I really wanted to implement gaps between the windows. So by looking at the suckless page I found this patch, the big issue I have with this patch is that if there is a single window on the screen the gaps are not effective on the outer borders and that's pretty shit. So I decided to build my own patch!

To begin with I got a clean version of dwm6.2 and patched it with the ru-fibonacci patch... And the compilation failed:

Looking at the gcc error I figured out that the structure mon was missing a variable gappx.

So then I run make again and it works! :) But when I run dwm the gaps aren't there because I forgot to set the gaps in the source code. So let's do that!

Now that I added the code to set the variable gappx the issue I have is clear in the next two images:

So now I will work on the value of the outer gaps. In the fibonacci.c file there's some useful information.

  1. The "if (n == 1) {" line: 8
  2. And the "resize(c, nx + mon->gappx, ny, nw - 2 * (c->bw) - mon->gappx, nh - 2 * (c->bw) - 2*mon->gappx, False);" line: 59
The first line is the source of my problems. It can be translated as, if number of lines is equal to 1, then set the size of the window to fill it. I don't want that. The second line shows me how the gaps are set when there is more than 1 window and that's the behavior I am looking for.

So I start simple I first implement the gaps on the top and left side of the window by adding those two " + mon gappx" and then recompile:

I then looked at how the width and height of the window is calculated by the resize that I noted above and " - mon->gappx" to the height and width

I'm starting to get there, at that moment I knew I was really close to the end of my little project! Looking back at that resize line I realized that they don't just remove the size of gappx to the width and height but that they double it before removing it, so I did exactly the same and TADAAA! it works :D


Thank you so much for reading this is my first post and my first blog. Please follow me on GitHub and this blog so you can be update on my new projects.

p3ng0s
arch linux iso

A linux distribution with my entire config pre-installed. Great for learning linux and pentesting with a steep learning curve.

wiki | repo
Similar content
Questions / Feedback
For any questions or feedback you can contact me on LinkedIn or twitter / X. I also use twitter as a platform to update on new posts!
Donate
sponsor me image

If you like the content of my website you can help me out by donating through my github sponsors page.