Tech News
← Back to articles

Moving Back to a Tiling WM – XMonad

read original related products more articles

Here are my dotfiles.

When I was still using Manjaro Linux back in 2019, I got a nudge to try i3wm. It was my first experience with any window manager. And I spent nearly 5 years with it, enjoying the absolute control over my workflow. Nearing the end of 2023, when I finally decided to leave Manjaro (for good), I had a bunch of options on my hand. Fedora looked really promising at that time. But even then, I wasn’t sure I was going to be using any tiling window manager. I happily switched to Gnome in Fedora 40. I ran it along with XOrg so that I could make my capslock key act as a ctrl when held and as an escape when pressed once, using setxkbmap and xcape . But only after spending a few months there, I realized I missed that finer control at my fingertips. So, I resumed searching for a newer tiling window manager. I was also learning Haskell at that time, so picking up XMonad was natural.

There are a lot of things that I like about XMonad apart from its standard tiling manager features. I enjoy writing the configuration in Haskell. Where ever possible, I try to leverage the benefits of Haskell’s strong type system. Defining keybindings with a strong type system ensures that I cannot go very wrong with it. Using stack for building my configuration allows me to port the entire configuration easily to other systems, which are my various virtual machines. I have split configuration in various modules.

src ├── Keybindings.hs ├── Layout.hs ├── Plugins │ ├── Bluetooth.hs │ ├── Pomodoro.hs │ └── Soundtrack.hs ├── Preferences.hs ├── Theme │ ├── Dmenu.hs │ ├── Font.hs │ ├── Theme.hs │ └── Xresources.hs ├── Workspaces.hs ├── xmobar.hs └── xmonad.hs 3 directories, 13 files

If you want to poke around the config according to your needs, go through Preferences.hs. It contains lots of variables which can be customized like terminal emulator, browser, scratchpads, window gap size etc. It also contains a list of applications which you would like to start automatically at boot.

Overall, the modularization has turned out to be pretty in terms of categorizing things. I tried writing a few xmobar plugins for my own needs. The guide for writing them was straightforward to begin with. I also wrote my entire xmobar configuration in Haskell itself, keeping this executable in the same project. In the end, the project itself became a one-shot way for an entire desktop environment which I can easily clone, compile and install on any system.

1. Setup

I will go briefly over the stack-based setup. The only thing needed is to have a build script at the root of your xmonad project. Everything else is simply a normal stack project with modules and a few executables. I have 2 executables in my project: xmonad and xmobar.

A detailed description and example build files can be found here. My build script is simple enough.

#!/bin/sh SRC_DIR = $HOME /.config/xmonad WM = xmonad unset STACK_YAML FAIL = 0 cd $SRC_DIR stack install 2 > .log || FAIL = 1 ln -f -T $( stack exec -- which $WM ) $1 2 > .log || FAIL = 2

... continue reading