In a previous post, we talked about how to patch suckeless software using patch. There are some limitations to that approach.

  • most patches are poorly maintained
  • patches tend to apply to vanilla (unedited) versions of the software
  • many patches fail and require manual intervention
  • using patch can lead to maintenance hell

It turns out that there are some alternatives to develop a more structured, and robust, way to extend suckless software. The main inspiration came from this article, How to create and apply a patch with Git.

The workflow that I started using is as follows:

  1. Clone the suckless software you want on your local machine.
  2. Create a repo on GitHub for the software.
  3. Upload the local, vanilla, version of the software to GitHub.
  4. Tag the version as the clean version.

At this point, if you have a tag that you can use to always revert to the original build of the tool with:

  • git clone -b <tagname> <repository>

With this, you can always check if patches apply cleanly to the original version of the software. However, in reality, you’ll have to apply patches on top of each other. The way I do it is to:

  1. Create a new branch every time I want to install a patch.
  2. Implement the patch — I do this manually most of the time.
  3. Commit and push my changes from the branch.
  4. Merge the pull request (I prefer to do this manually on GitHub).
  5. Create a new tag for the new patch.

At this point, you have software that you can keep extending. When you need to clean things up, you can always download or pull the latest tag for the repo. To make the process handy, I created a couple of shell scripts. Here’s my dwm build.