i3 to XMonad - How and why

Never thought I’d see this day, but I actually found a new Tiling Window Manager for my Linux system, I went past i3wm for once just to experiment, and don’t see myself coming back any soon. So yeah, XMonad it is.

Never heard of it? Very probable. If 1-10% of the PC users are capable of using a Linux system properly, out of those about 1-10% are capable of using i3wm; then out of the remaining few, I guess again only 1-10% would gain anything from using XMonad, for if you want to be able to make XMonad better than i3wm, you need to Code, and I mean actual code. Not just scribbling in a plaintext file with some default keywords you google or read on the i3wm website. What’s more daunting is that this isn’t Python code, its Haskell, probably one of the most tough languages to code in for average people.

Still here? Good news, no more scaring! I’ll jump to the reasons why you should try out XMonad:

  1. A really nice way to learn Haskell (Ha! Yeah, I installed it just to be able to start somewhere in Haskell.)
  2. Much more configurable than i3wm and perhaps most other tiling window Managers (haven’t tried awesome and dwm)
  3. Tiling at its best. i3wm offers manual tiling, you tile windows the way you want to. XMonad does it itself. You can define your layouts and XMonad tiles the windows in those layouts. ‘Automatic Tiling’.
  4. A fresh take at multi-monitor support. XMonad lets you swap Windows between your monitors in a breeze. I found that I can work much better this way, Bring whatever I am working on onto the larger monitor and keep the other workspace on the secondary one as reference. This works amazingly fine for me.
  5. Taffybar. So mostly where you’d read about XMonad, most people go with a dzen2 or a xmobar based top-bar (or bottom bar). These 2 certainly are nice, but Taffybar is the bar for me. Again, its coded in Haskell and you actually write Haskell code to configure it. Another learning opportunity :D
  6. Light weight and bug free :D (so far)
  7. No need for mouse (just like i3wm). That is, if you use Vimium for Chrome or Vimperator for Firefox (if you don’t, you should be using them).

Enough of reason listing, how do you get to use it? Ubuntu:

sudo apt-get install xmonad suckless-tools

Funny name, suckless-tools.. Well they have a package named dmenu you’d be using extensively. No more finding apps in some application drawer. Just type.

Arch:

sudo pacman -S xmonad dmenu

Logout of your current desktop session (NOT NOW, after you have read the following). Now login again, selecting XMonad when you login. You’d be dropped to an empty black screen which does nothing. Funny. alt+shift+return would open a new terminal. alt+p would open the dmenu at the top. Open firefox or chrome and get back to the safe haven of a web browser :P Now that you survived this, it’s time to learn some shortcuts. But before that, a few tips:

  • Look at the default complete-config. Here’s the link. This file contains most of the code you should be using initially.
  • You’ll never get the hang of things till you actually code them. How I proceeded was by reading lots and lots and lots of config files of people on Github.
  • Hack on the source code. Look at the sources of different libraries you are using and see how they define things, the Syntax and all.

Configuration is pretty simple. You just go ahead and create a directory ~/.xmonad/ and create a new file xmonad.hs there.

Here’s a sample xmonad.hs taken from the Arch Wiki.

import XMonad

main = do
  xmonad $ defaultConfig
    { terminal    = myTerminal
    , modMask     = myModMask
    , borderWidth = myBorderWidth
    }

myTerminal    = "urxvt"
myModMask     = mod4Mask -- Win key or Super_L
myBorderWidth = 3

Well I haven’t explained much about the configs, and I know it. I cannot help it, as it mostly involves Haskell (and that means people already comfortable with Haskell would find it pretty easy). I’ll follow up about various configuration options in XMonad in another set of articles here at AceHack. I leave you to explore XMonad if interested.

Oh and I almost forgot, here’s the link to my xmonad.hs. , and it’s pretty tweaked. Note that I put almost all my main code in files inside the folder lib. You can import them with their names as I have done in my xmonad.hs. warning, many of the keybindings have been changed to those of i3wm so as not to break my muscle reflexes developed from using i3wm for almost 8 months. Ha, i3wm is still one of my favs, and it’s keybindings certainly are the best.