Xmonad/Using xmonad on Apple OSX

From HaskellWiki
< Xmonad
Revision as of 02:03, 10 April 2009 by Sereven (talk | contribs) (Installing XMonad: add contrib install recommend)
Jump to: navigation, search

xmonad runs well under X11 on Apple OSX machines, and needs little work to be useful. This page collects advice and information on using xmonad successfully with OSX.

If you're using xmonad on a mac, add details about your configuration here!

Installing on OSX Tiger

Installing XMonad

  • ghc: You can get from haskell.org/ghc, MacPorts, or Fink. Fink has an older version of ghc -- one that will work with xmonad (for now?), but will make baby xmonad cry.
  • X11 lib: Get from hackage.haskell.org, build using the standard Cabal steps. Make sure that Xinerama gets detected in the configure step. If you see a "present but not compiled" warning, that might be okay (it worked for me).
  • xmonad and xmonad-contribb: Get from hackage.haskell.org, build using the standard Cabal steps.

I installed into my home directory by adding "--user --prefix=$HOME/usr" to the configure steps. The default is /usr/local.

Configuring Your .xinitrc to Run XMonad

  1. Build and install XMonad like you would any other Haskell library.
  2. do the following on the Terminal:
         $ cp /private/etc/X11/xinit/xinitrc ~/.xinitrc
         $ chmod +w ~/.xinitrc
         $ vim ~/.xinitrc 
         #comment out the line 'exec quartz-wm' and add PATH-TO-XMONAD/xmonad after it.
  3. You may want to add quartz-wm --only-proxy & to your xinitrc, which synchronizes X11/OSX clipboards.
  4. Open X11. XMonad should be running now.

Configuring Xmonad for OS X

  • You probably don't have a numlock key. Set numlockMask to 0. (The default is mod2Mask, which happens to be Apple's default for the command key.)
  • You may use the defaultGaps to make xmonad not clash with the dock. As the dock size is configurable and may vary depending on the number of icons in the dock you will have to measure your dock yourself. Before 0.7 defaultGaps are in xmonad, since 0.7 these should be in xmonad-contrib.

Full screen mode

I highly recommend running X11 in full-screen mode. To enable this, open the Preferences dialog for the X11 app, check the checkbox, and restart X11. This way, you don't have to worry about stupid things like the dock / menubar / OS X apps getting in your way.

Does Not Replace Quartz, Silly

You won't be able to use xmonad to manage normal OS X apps. X11 will just be another OS X application sitting in your dock that you can switch to. However, it is pretty easy to install a decent set of X11 apps. If you have MacPorts installed you can install the packages firefox-x11, rxvt-unicode, unclutter, and 'vim +gtk2' (the +gtk2 variant for PRIMARY/CLIPBOARD support) to get started.

Fitting Other Bits For Use With xmonad on OS X


dmenu can be built on OS X without problems but it is invisible unless you run X11 in full-screen. Unlike xmonad it does not detect the OS X top menu bar and is completely hidden by it. You can also make it display at the bottom (behind the dock :).

Since I do not know how to detect the top menubar either I just patched dmenu to add support for gaps. Unfortunately the dmenu authors do not seem very responsive so I attach the patch here.


You can then run dmenu -g 22 to work around the OS X top menu.

Potential Configuration Problems

You may have problems with configuring XMonad under OSX - if you see the "error detected while loading xmonad configuration" error message but with no error output, it could be because the PATH inherited by XMonad doesn't include ghc (eg by default it won't include /usr/local/bin).

Possible solutions:

  1. http://forums.macosxhints.com/showthread.php?s=&threadid=12382
  2. http://forums.macosxhints.com/showthread.php?t=14279
  3. Or just hardwire the path into xmonad itself - change "ghc" -> "/usr/local/bin/ghc" (or whatever) in Core.hs before building XMonad.

Installing on OSX Leopard

These instructions have been tested on a blank but fully updated system (04/04/09).

Installing xmonad

Installing GHC

  1. Install xcode, this can be found on the OSX install disk; it can also be downloaded from apple (you will have to sign upto a free developer account).
  2. Download and install ghc.

Installing Cabal

  1. Download and extract Cabal install from http://www.haskell.org/cabal/download.html
  2. In a terminal:
    $ cd ''Cabal install directory''; ./bootstrap.sh
  3. Edit your path to contain ~/.cabal/bin . This can be achieved by adding
    to ~/.profile
  4. Open a new shell (the path variable will only take effect on new shells).
  5. Update cabal
    $ cabal update
  6. Install xmonad
    $ cabal install xmonad

Install dmenu (optional but recommended)

  1. Download and extract dmenu from http://tools.suckless.org/dmenu
  2. $ cd ''dmenu directory''; sudo make install

Updating X11

The version of X11 shipped with Leopard (04/04/09) does not support going fullscreen. I recommend updating X11. It is likely that a Leopard update will eventually make this step unnecessary. Download and install the latest version from macosforge.

Configuring Your .xinitrc to Run XMonad


export USERWM=`which xmonad`
exec /usr/X11/lib/X11/xinit/xinitrc

to ~/.xinitrc

Alternatively, if this doesn't work (because you haven't updated X11): write:

export USERWM=`which xmonad`
exec $USERWM

to ~/.xinitrc

Make sure your PATH variable is set up correctly in ~/.profile. Xmonad and dmenu should be in the path. Anything you want to launch from dmenu should be in the path.

Configuring Your Keyboard

I can't find the meta key (xmonad is unusable without it) in the default configuration. I followed this guide (write

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

to ~/.Xmodmap) and now the meta key is the left alt.

Further Configuring

  • The menu bar shouldn't get in the way (fullscreen or otherwise, updated or standard X11). The Dock however will, I recommend hiding the Dock or always working in fullscreen mode.
  • You can start X11 (and Xmonad) by running any program that uses X, or by running X11.app. If you run X11.app a default program is started. You can configure this program by running
     $ defaults write org.x.X11 "app_to_run" "gnome-terminal" 
    (replace gnome-terminal with a program of your choice). or
    $ defaults write org.x.X11 "app_to_run" ""
    to have no application run by default.
  • There shouldn't be anything unusual about configuring ~/.xmonad/xmonad.hs.


  • XMonad and Vimperator (Firefox 3 extension) make a powerful combination on Linux. I cannot achieve this on OSX because the newest X11 version of Firefox I can install is version 2. If anyone has any hints on installing Firefox 3 X11 please share them.
  • XMonad only works with X11 software- a package manager such as Port is helpful http://www.macports.org/ .