xmonad 101: Welcome to xmonad

After seeing Nick using it at work, I decided to give xmonad a go as my window manager. I remember giving awesomewm a go once upon a time, but I didn’t really know what was going on and went back to gnome.

I’m far from comfortable, but I thought I’d document how I’ve got things set up so far. When I talk about the mod key, I’m talking about left alt.

Launching apps

When you first log in, you can press mod+shift+enter to bring up a terminal. You can launch apps through there, but I’d recommend installing suckless-tools for the dmenu package. I also installed xmobar as this nice post told me to. Now I know what it does, I’d say it was a good idea. So, the commands:

sudo apt-get install xmobar suckless-tools

And you’ll need to create the following config files:


import XMonad
import XMonad.Util.Run(spawnPipe)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

main = do
    xmproc <- spawnPipe "/usr/bin/xmobar ~/.xmobarrc"
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> manageHook defaultConfig
        , startupHook = setWMName "LG3D"
        , layoutHook = avoidStruts $ layoutHook defaultConfig
        , logHook = dynamicLogWithPP $ xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50


Config  { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
        , bgColor = "black"
        , fgColor = "grey"
        , position = Top L 90
        , commands = [ Run MultiCpu ["-t", "CPU: <autototal>%","-L","3","-H","50","--normal","green","--high","red"] 10
                        , Run Memory ["-t","Mem: <usedratio>%"] 10
                        , Run Swap [] 10
                        , Run Date "%a %b %_d %l:%M" "date" 10
                        , Run Network "eth0" [] 10
                        , Run StdinReader
        , sepChar = "%"
        , alignSep = "}{"
        , template = "%StdinReader% }{ %multicpu% | %memory% * %swap% | %eth0% | %date% "

I customised the .xmobbarrc file a bit as I didn’t want to see battery life or wlan0 traffic (I’m on a cabled up desktop), but you can see the original config here

Setting your desktop background

You’ve got two options here. If you want one image to be spread across multiple monitors, you’ll want to use xloadimage

sudo apt-get install xloadimage && xloadimage -center -onroot -fullscreen /path/to/image

Personally, I like the wallpaper to fit on each screen, so I prefer feh.

sudo apt-get install feh && feh --bg-fill /path/to/image


That’s everything that I’ve done so far. I’m gonna give it a go on my home PC when I get chance, so documenting the process here is useful. If you have any suggestions how to get the most out of xmonad, let me know.

December 04, 2012

How To