This post is also available in: Italian

I’ll write here my configuration of xmonad in order to find it easily in the future. xmonad is a dynamically tiling X11 window manager that is written and configured in Haskell (http://xmonad.org/). I find xmonad really useful on systems with small screens and on laptops to avoid using the touchpad.

Software

xmonad (0.8) – the window manager xmobar (0.9) – a status bar also in haskell trayer (1.0) – small app for a systray feh (1.3.4) -to set the background image gdm, kmix, network-manager, …

How to install stuff

You’ll find more or less all the software needed on the repositories of the distribution of your choice (if you use ubuntu, like me, this should install the window manager apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools ).

Configuration

Following the config files of the various softwares:

xmonad – ~/.xmonad/xmonad.hs

import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run(spawnPipe) import XMonad.Util.EZConfig(additionalKeys) import System.IO myManageHook = composeAll [ className =? "Gimp" --> doFloat , className =? "Vncviewer" --> doFloat ] main = do xmproc <- spawnPipe "xmobar" xmonad $ defaultConfig { manageHook = manageDocks <+> myManageHook -- make sure to include myManageHook definition from above <+> manageHook defaultConfig , layoutHook = avoidStruts $ layoutHook defaultConfig , logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmproc , ppTitle = xmobarColor "green" "" . shorten 50 } , modMask = mod4Mask -- Rebind Mod to the Windows key } `additionalKeys` [ ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s") , ((0, xK_Print), spawn "scrot") ]

xmobar – ~/.xmobarrc

Config { font = "-misc-fixed-*-*-*-*-13-*-*-*-*-*-*-*" , bgColor = "black" , fgColor = "grey" , position = TopW L 85 , commands = [ Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10 , Run Cpu ["-L","15","-H","50","--normal","green","--high","red"] 10 , Run Memory ["-t","Mem: %"] 10 , Run Swap [] 10 , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 , Run StdinReader ] , sepChar = "%" , alignSep = "}{" , template = "%StdinReader% }{ %cpu% | %memory% * %swap% | %wlan0% | %date%" }

gdm – /usr/share/xsessions/xmonad.desktop

[Desktop Entry] Encoding=UTF-8 Name=XMonad Comment=Leightweight tiling window manager Exec=xmonad.start Icon=xmonad.png Type=XSession

xmonad.start is a custom script.

xmonad.start – /usr/local/bin/xmonad.start

#!/bin/bash xrdb -merge .Xresources trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 15 --height 12 --transparent true --tint 0x000000 & gnome-screensaver gnome-settings-daemon if [ -x /usr/bin/gnome-power-manager ] ; then sleep 1 gnome-power-manager fi if [ -x /usr/bin/nm-applet ] ; then nm-applet --sm-disable & fi kmix --keepvisibility #feh --bg-scale /mnt/archivio/foto/2008-2009-dublino/2009-04-10-stefano/hapenny-desktop.jpg & exec xmonad

Notes:

using gnome-settings-daemon (i.e. for multimedia keys) the use of feh for setting the background image is unnecessary.

Screenshots

A screenshot of the desktop without applications (only xmonad and trayer), the background image is the Ha’Penny Bridge, Dublin, by Steve:

now with some apps: