October 27, 2007

Installing Xmonad on Ubuntu

Xmonad is the new kid on the block among the tiling window managers. Tiling window managers (some of the other prominent ones being ratpoison, dwm or Ion, arrange windows automatically to tile the screen without overlap or gaps, maximizing screen usage. To those who remember the tiling windows in old Windows and Mac systems, this might seem like a step backward. But in todays world of wide screen monitors and multi-head displays, tiling window managers can be highly productive, not to mention the fact that the mouse is mostly superfluous in most of these window managers. Anyway, it doesnt hurt to try it out and a choice of window managers is one of the fantastic things about Linux. If you just want to try out a tiling window manager, dwm is available in the Ubuntu repos. But if you want to try Xmonad, you have to build it from source. This is what worked for me. Most of the instructions are based on those given at the site, but some modifications are needed for the specific dependencies in Ubuntu and to install the latest version of Xmonad. These are the instructions for installing on Ubuntu Feisty and have not been tested on Gutsy.

1. Install the Haskell compiler and the mtl core library.

sudo aptitude install ghc6
sudo aptitude install libghc6-mtl-dev

2. Download and install the X11 bindings for Haskell

cd /tmp
wget http://hackage.haskell.org/packages/archive/X11/1.2.2/X11-1.2.2.tar.gz
tar -xzf X11-1.2.2.tar.gz
cd X11-1.2.2
runhaskell Setup.hs configure --prefix=$HOME
runhaskell Setup.hs build
runhaskell Setup.hs install --user
cd ..

3. Download and install the X11-extras bindings

wget http://hackage.haskell.org/packages/archive/X11-extras/0.4/X11-extras-0.4.tar.gz
tar -xzf X11-extras-0.4.tar.gz
cd X11-extras-0.4
runhaskell Setup.lhs configure --prefix=$HOME
runhaskell Setup.lhs build
runhaskell Setup.lhs install --user
cd ..

4. Install dmenu and dzen (Optional, provides status bar and menu)

sudo aptitude install dmenu

wget http://gotmor.googlepages.com/dzen2-latest.tar.gz
tar -xzf dzen2-latest.tar.gz
cd dzen2-0.8.5
sudo make clean install
cd gadgets
sudo make clean install

5. Download and build Xmonad

mkdir ~/xmonad
cd ~/xmonad
wget http://hackage.haskell.org/packages/archive/xmonad/0.4/xmonad-0.4.tar.gz
tar xzf xmonad-0.4.tar.gz
cd xmonad-0.4
runhaskell Setup.lhs configure --prefix=$HOME
runhaskell Setup.lhs build
runhaskell Setup.lhs install --user

Note that I have opted to store the xmonad source files in an accessible directory. Dont delete it yet. Any changes in the configuration of Xmonad are made in the source code and then you have to recompile the binary.

The best way to add xmonad to the gdm menu is to create a .xsession file. In the simplest form this will be


Now when you log in you will have an option titled 'xsession script' and choosing it will launch xmonad. Look at the xmonad site to learn the keyboard shortcuts before you start. We have to configure xmonad to create a space for dzen and write some scripts to pipe some output to the dzen status bar. This and other customizations in the next post.

See my next post for setting up Xmonad.


Unknown said...

A useful walkthrough!

I think it should be --prefix $HOME and not --prefix=$HOME unless you want to store the binary in a '=' subdir relative to the xmonad build dir

also it is possible to have xmonad coexist with GNOME now, see for instance http://xmonad.org/gnome.html

Raja said...

Thanks Jan,
I can confirm that '--prefix=$HOME' is correct for all the configures.
Yes - it is possible to have xmonad as the window manager in gnome (replacing metacity). May be useful for those wanting to retain all the other gnome goodies.

Anonymous said...

For the installation of the xmonad package, I had to add the '--user' option to 'runhaskell Setup.lhs configure --prefix=$HOME'. It seems to tell setup that it should look for X11 in the user database instead of the global package database; it will complain about not having the correct version otherwise.

Hope it helps.