Minimalist X window managers – xmonad on Apple OS X Snow Leopard (10.6)

This post will outline the steps you can use to build xmonad cleanly on a Snow Leopard system.

This is a follow-up post to our prior post on minimalist X window managers on OS X which addressed xmonad and ratpoison on OS X Leopard.

The rationale and benefits of a simple and clean X11 window manager on OS X are outlined clearly in that post.

Thanks to baconpiggypiggy for testing and sharing test patches for making this work on Snow Leopard, in the interest of more efficient desktops everywhere.

It was previously possible by bootstrapping binaries from previous OS X builds, various source patches, etc., but it is quite exciting to have it available for simple and easy setup. These steps should work whether you are booting into 32-bit or 64-bit mode.

The steps are as follows:

1. Be running a relatively vanilla Snow Leopard installation.

2. Run the “Optional Installs” installer from the Snow Leopard media. Under “Applications”, find “X11” and install it on your system.

3. Install Xcode from the Snow Leopard media.

4. Run Software Update to address any Xcode updates.

5. Download and run through the installer for the Glasgow Haskell Compiler (GHC) (latest is version 6.12.1 as of posting).

6. Launch Terminal.app and run this script to install the Haskell X11 library

cd /tmp
umask 022
curl -O http://hackage.haskell.org/packages/archive/X11/1.5.0.0/X11-1.5.0.0.tar.gz
tar xfz X11-1.5.0.0.tar.gz
cd X11-1.5.0.0
runhaskell Setup.hs configure
runhaskell Setup.hs build
sudo runhaskell Setup.hs install

7. Run this script to install the Haskell MTL library:

cd /tmp
umask 022
curl -O http://hackage.haskell.org/packages/archive/mtl/1.1.0.2/mtl-1.1.0.2.tar.gz
tar xfz mtl-1.1.0.2.tar.gz
cd mtl-1.1.0.2
runhaskell Setup.hs configure
runhaskell Setup.hs build
sudo runhaskell Setup.hs install

8. Run this script to install xmonad:

cd /tmp
umask 022
curl -O http://hackage.haskell.org/packages/archive/xmonad/0.9.1/xmonad-0.9.1.tar.gz
tar xfz xmonad-0.9.1.tar.gz
cd xmonad-0.9.1
runhaskell Setup.lhs configure
runhaskell Setup.lhs build
sudo runhaskell Setup.lhs install

9. Launch X11, and set a few settings in preferences. On the “Input” tab, ensure that only the following two options are checked: “Emulate three-button mouse”, and “Enable key equivalents under X11”. Close X11.

10. Pull down awesome X11 fonts from proggyclean.

11. Save them in ~/Desktop/fonts/ or a directory of your choice. Gunzip the PCF files.

11. Run mkfontdir in the directory to create a fonts dir file.

12. Copy over the stock xinitrc: cp /usr/X11/lib/X11/xinit/xinitrc ~/.xinitrc

13. In ~/.xinitrc, comment out the if/for loop that runs the stuff in /usr/X11/lib/X11/xinit/xinitrc.d/ twm, clock, and the xterms.

14. Append to ~/.xinitc:

/usr/X11/lib/X11/xinit/xinitrc.d/10-fontdir.sh
xset fp+ ~/Desktop/fonts
xset fp rehash
cd
quartz-wm --only-proxy &
/usr/local/bin/xmonad &
xterm

15. Create ~/.Xmodmap with the following contents:

clear Mod1
clear Mod2
keycode 63 = Mode_switch
keycode 66 = Meta_L
add Mod1 = Meta_L
add Mod2 = Mode_switch

16. Create ~/.Xdefaults with the following contents (adjust the font name if you selected a font other than ProggyTiny with slashed zero):

XTerm*font: -*-proggytinysz-medium-*-*-*-10-*-*-*-*-*-*-*
XTerm*reverseVideo: on
*VT100*reverseVideo: on

17. Launch X11. Enjoy!

A couple of notes:

  • Cut and pasting:
    • within X11 only, you can highlight text and it will be placed on the clipboard
    • to put it on the clipboard for aqua apps, hit command-c as usual with aqua apps
    • to paste within X11 (from either X11 or aqua), just use option-click or middle-click
  • window and virtual desktop layout:
    • ctrl-n – new xterm
    • option-1 through option-9 will take you through different workspaces in xmonad, which are independent of OS X “spaces”
    • option-. and option-, will rotate and redo tiling of windows

This setup and tmux are a winning combination for maximum OS X command line efficiency.