BAM Weblog

OSXMonad as an XMonad library

Brian McKenna2012-07-29

This week I managed to get OSXMonad running as an XMonad library.

That means you can write a ~/.xmonad/xmonad.hs file like so:

import XMonad
import OSXMonad.Core

main = osxmonad defaultConfig

And the xmonad command will launch OSXMonad to manage Cocoa windows using the default XMonad configuration. Hardly any XMonad features work except some layouts at the moment, but it's still pretty cool to see:

I've been working on support for key bindings. Things like this currently work:

main = osxmonad defaultConfig {
         modMask = mod1Mask .|. mod4Mask,
         keys = \(XConfig {XMonad.modMask = modMask}) -> M.fromList [
                 ((modMask, xK_a), io $ putStrLn "Test")

Which means that when you press "⌥-⌘-a" then "Test" will be printed to the command line. It's a start.

I had to modify the XMonad source. The xmonad command usually calls out to GHC like so:

ghc --make xmonad.hs -i -ilib -fforce-recomp -v0 -o $binn

But I needed to to be compiled with -framework Cocoa for my Cocoa calls to be linked correctly. I just hard-coded the change and added a Darcs patch to the OSXMonad repo. I'll eventually turn it into a patch to allow additional GHC flags to be given to the xmonad binary.

I've added a README for anyone interested in getting started.

Please enable JavaScript to view the comments powered by Disqus.