vendredi 11 septembre 2009

Working tiled and comfy on MacOSX : X11, dwm, urxvt, Terminus

From Jérôme Andrieux


(Easiest thing to do is not to use MacOSX in the first place, however
for those among us who actually like to work with terminals, text mode
apps and funky tiling window managers and all those tools that actually
suck less, things were made easy).

For those who just want to tile some windows, Quicksilver and some
applescript could do.

Get Prerequisites



  • MacOSX Leopard. I think one could get this working on Tiger, but
    not sure.

  • X11 packages from Leopard (default install, X11User et X11SDK
    packages from the additionnal softwares folder on the install DVD) or
    XQuartz. I had
    some problems with Xquartz 2.4.0 so I wouldn't recommend it.

  • Macports. Macports provides
    lots of brilliant softwares, among them urxvt and terminus-font.
    Macports requires Xcode.

  • dwm sources from the mercurial repo or the tarball, see here. dwm is, well, you know
    dwm.



Test your setup :

$ pkgutil --pkgs | grep X11
com.apple.pkg.X11User
com.apple.pkg.X11SDKLeo
com.apple.pkg.X11DocumentationLeo


Launch "X11.app" from Application/Utilities. From xterm, type in "xev"
and press your Option/Alt keys to obtain their keypres. You will need
those keypres later to define the dwm modifier key.

Install


dwm configuration is done at compile time by editing the header file :

$ cd path/to/dwm
$ vi config/def.h
# edit to fit your needs, note modifier key
$ make


Then install the other apps :

$ sudo port install rxvt-unicode
$ sudo port install terminus-font


At this point, Terminus font is not available in xfontsel, we need to do some
configuration.

Configure X11 session



Things you want when starting X11 :

  • launch dwm at startup

  • have a working keyboard layout

  • have a working ssh-agent

  • being able to copy/paste from/to X11/Aqua



Edit ~/.Xmodmap (I use left Alt 66 as Mod1 and right Alt 69 as normal Alt ie
options in MacOSX).:

clear Mod1
keypre 66 = Alt_L
keypre 69 = Mode_switch
add Mod1 = Alt_L


Edit ~/.xinitrc :

# if you need to customize some PATH or ...
. ~/.bashrc
# may be useless, should handle clipboards
ssh-agent quartz-wm --only-proxy &
# load your keyboard configuration, should be read by xinit
# automagically, just in case
xmodmap ~/.Xmodmap &
# add Macports/terminus fonts to X11
xset fp+ /opt/local/share/fonts/ &
xset fp rehash &
~/path/to/dwm/dwm


You could as well edit ~/.Xdefaults to setup rxvt look and feel :

URxvt.perl-ext-common: default,matcher
URxvt.urlLauncher: open
URxvt.matcher.button: 2
URxvt*font: xft:terminus
URxvt*boldFont: xft:terminus:style:Bold
Rxvt.foreground: white
Rxvt.background: #222222
Rxvt.cursorColor: white
Rxvt.reverseVideo: false
Rxvt.scrollBar: false
Rxvt.meta8: true
Rxvt.modifier: mod1


Moar Terminus!@#



if you were to like Terminus enough to want it in Terminal.app, I
recommend you use Jeramey package from http://jeramey.livejournal.com/124733.html.