Minimalist X window managers on Apple OS X Leopard (10.5)

Updates:

  • 3/5/2010 – Snow Leopard xmonad configuration detailed in this follow-up post
  • 12/25/2009 to fix several hours and point out functionality of Fluxbox and Blackbox on Snow Leopard.

Perhaps you have used a full-time *NIX box as your main desktop in the past.

In many cases, you will probably find that many of those folks are just using Apple machines now, due to the aesthetics of the hardware, ease of native use of Windows and *NIX applications, giving you the best of all three worlds (licensing is another topic . . . ).

This is a great way to stick with your normal OS X install, but be able to switch back to just X11 so you can have tons of windows open and be able to read everything quickly. This setup does not require any dual-booting, nerfing of copy/paste, etc.

I’ve been doing this with Leopard and Snow Leopard. I prefer xmonad, but haven’t succeeded in building it cleanly on fresh installs of Snow Leopard, so am providing two sets of instructions.

Ratpoison and xmonad are both very lightweight, minimalistic, fast window managers for X11. You’ll find that they both strive to be as simple and quick as possible to permit the fastest usage of lots of windows while allowing you to maximize the use of your screen real estate.

Ratpoison instructions will work for either Leopard or Snow Leopard. xmonad only works with Leopard at the moment, due to the 64-bit haskell compiler (GHC) build work being done for Snow Leopard.

They each allow you to dynamically create and remove workspaces that are independent within X11, and do not overlap with OS X’s “Spaces”.

xmonad stands out in a couple areas:

  • easy to rotate/resize/retile windows
  • a bit cleaner, simpler
  • mouse highlighting to switch windows

Try them out.

Other applications like tmux may be helpful to create another dimension of windows and flexibility.

Fluxbox and Blackbox are both fairly simple and clean, and each have functional ports available from MacPorts, so you can copy the settings below for Ratpoison and use those if you are interested.

1. Load X11 and XCode development tools from Apple OS X media.

If you want to use xmonad, perform the following steps, or skip to step 6 for Ratpoison. (Leopard only at this point)

2. Download the GHC package for Apple Leopard (same package for Leopard and Snow Leopard at this time)

3. Download the GHC X11 source package (bottom of page)

4. Install the Haskell X11 package:

tar xf X11-1*tar*
cd X11-1*
runhaskell Setup.hs configure
sudo runhaskell Setup.hs build
sudo runhaskell Setup.hs install

5. Install xmonad; pull down the latest source core distribution from the xmonad site

tar xf xmonad-0*tar*
cd xmonad-0*
sudo runhaskell Setup.lhs configure
sudo runhaskell Setup.lhs build
sudo runhaskell Setup.lhs install

If you want to use Ratpoison, perform the following steps, or skip to step 8. (Leopard or Snow Leopard)

6. Install MacPorts using their instructions.

7. Install Ratpoison: sudo port install ratpoison

Combined steps for either window manager.

8. 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
Enable key equivalents under X11

9. Close x11.

10. Pull down awesome X11 fonts from proggyclean. Save them in ~/Desktop/fonts/ or a directory of your choice. Gunzip the PCF files.

11. Open a command prompt and 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 twm, clock, all the xterms, and the if/for loop that runs the stuff in /usr/X11/lib/X11/xinit/xinitrc.d/

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 &
if [ -f /usr/local/bin/xmonad ]; then
/usr/local/bin/xmonad &
elif [ -f /opt/local/bin/ratpoison ]; then
/opt/local/bin/ratpoison &
fi
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.

Welcome to faster scrolling, paging action, and nice automatic (and fast!) tiling of windows.

A couple of notes:

  • Cut and pasting:
    • within x11 only, you can highlight text and it is 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
  • xmonad specific:
    • ctrl-n – new xterm
    • meta-1 through meta-9 will take you through different workspaces in xmonad, which are independent of your built-in virtual desktops in OS X
    • meta-. and meta-, will rotate and redo tiling of windows
  • Ratpoison specific:
    • ctrl-t, s – split vertically
    • ctrl-t, S – split horizontally
    • ctrl-t, tab – moves focus
    • ctrl-t, c – creates new terminal window
    • ctrl-t, ? – help and tips

The only real issue I have with this approach is that I rarely have windows strictly 80 characters wide, so that makes it harder to visually realize when I should be wrapping lines. Luckily nvi(1) and fmt(1) have that covered for me.

Hat tip to Eric Hanson for pushing me in the xmonad direction!

Author: George Lewis

Topic(s): How to,Technical

Published: October 26, 2009 00:05