Skip to content

Instantly share code, notes, and snippets.

@danchoi
Created October 20, 2012 13:08
Show Gist options
  • Save danchoi/3923233 to your computer and use it in GitHub Desktop.
Save danchoi/3923233 to your computer and use it in GitHub Desktop.
My Xmonad installation recipe for OS X Lion

My Xmonad recipe for OS X Lion

My recipe for setting up Xmonad on Ubuntu GNU/Linux is here.

What is xmonad? Read this page to learn.

Some of these instructions were adapted from the Source Matters Blog. But I also depart from those instructions in certain ways.

First, download XQuartz. It's a replacement for the stock X11 utility that seems to work better with xmonad as far as TrueType fonts and keymappings are concerned.

Start up XQuartz, open Preferences.

  • Under the Input tab, enable "Enable three button mouse" and "Option keys send Alt_L and Alt_R."
  • Under the Output tab, set Colors to "millions". Don't select Full-Screen mode.
  • Under the Pasteboard tab, enable all options.
  • Under the Windows tab, I like choosing "Focus Follows Mouse."

Quit XQuartz.

For the following steps, you will need Homebrew. I'll assume you have it already.

Next brew install ghc haskell-platform if you don't already have Haskell.

Next, install xmonad with cabal install xmonad.

Create an ~/.xinitrc file. This will be read when you start XQuartz & launch xmonad immediately.

[[ -f ~/.Xresources ]] && xrdb -load ~/.Xresources
cd $HOME
xterm &
$HOME/.cabal/bin/xmonad

Create a ~/.Xdefaults file. Put this in it:

xterm*Background:               black
xterm*Foreground:               green
xterm*cursorColor:              purple
xterm*pointerShape:             arrow
xterm*pointerColor:             red
xterm*faceName: Monaco
xterm*faceSize: 9

Now restart XQuartz. You should be in xmonad. Press ALT+SHIFT+ENTER to open new window tiles. If xmonad seems unresponsive at first, click on the first xterm window to start capturing keyboard input.

You can change the colors, pointer, fontName and faceSize in .Xdefaults. To see what fonts you can choose from use this command: fc-list | less.

To paste the contents of the pasteboard into an xmonad terminal, hold down OPTION and click the mouse/trackpad button.

To change font sizes for a particular window, you can use the popup xterm font menu, invoked with CTRL+COMMAND+click.

@mrpardijs
Copy link

I spend an evening trying to get xmonad under OSX Mountain Lion to work, but with little success... I followed this guide, and read the article on sourcematters, I end up with having X11 configured as not run in Full screen, when I then start XQuartz app, I can start various xterms, or xlogo, or xman by pressing Mod-return, and switch to the default xmonad layouts, but don't get the idea how to manage opening other applications such as my browser or, for example, the Notes app.
Can you explain how this should work and how to accomplish this?

@jbeard4
Copy link

jbeard4 commented Jul 1, 2013

Hi, very helpful!

I found that out of the box, X11 xterm behaved very differently from iTerm.app. For example, the path would not be set correctly, and it would not respect the default shell set in iTerm with chsh. I found the solution to this, and committed it in my fork: https://gist.github.com/jbeard4/5898283/revisions

@jsdt
Copy link

jsdt commented Aug 9, 2013

I had to use /Users/$USER/Library/Haskell/ghc-7.6.3/lib/xmonad-0.12/bin/xmonad in my xinitrc, but besides that it worked perfectly. Thanks.

@josiah14
Copy link

I got close to getting XMonad to work with Mountain Lion. Here are the steps I had to follow - plus some links that I didn't feel like copying everything from (the generally easy to find links on Google concerning getting XMonad on Mac).

  1. Install XCode 5

  2. install command line tools via XCode menu -> Preferences -> Downloads

  3. Install Homebrew
    at http://brew.sh
    ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
    brew update
    brew tap homebrew/versions

  4. install XQuartz
    xquartz.macosforge.org/landing/

  5. install macports (just download from the site and follow the installer directions)
    PATH=/opt/local/bin:$PATH

  6. brew install ghc
    (installs ghc 7.6.3)
    sudo port install gcc_select
    sudo port install gcc47 # this step takes a while
    port select --list gcc # to see versions
    sudo port select --set gcc mp-gcc47
    hash gcc

    vim /usr/local/Cellar/ghc/7.6.3/lib/ghc-7.6.3/settings
    edit ("C compiler command", "/usr/bin/gcc"),
    to be ("C compiler command", "/opt/local/bin/gcc")
    cabal update
    cabal install cabal-install

  7. Install XMonad
    cabal install xmonad
    brew install pkg-config
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/X11R6/lib/pkgconfig
    pkg-config --variable pc_path pkg-config
    cabal install xmonad-contrib

https://gist.github.com/pyrtsa/6213784
https://gist.github.com/danchoi/3923233
http://www.haskell.org/haskellwiki/Xmonad/Using_xmonad_on_Apple_OSX

Now I'm getting an error related to XMonad seemingly not having the permissions to resize X11 windows. I want to tinker a bit with this before asking for help, but I thought I would put these steps out there for others to see if someone might be able to use these to get closer to figuring out how to get XMonad fully working on Mountain Lion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment