projects | github | twitter | rss | contact

running multiple x11 instances under mac os

posted to writings on jul 27th, 2009 with tags mac, nerd, openbsd, and ratpoison

i am heavily using x11 under mac os x with ratpoison as my window manager. combined with mac's "spaces", this basically gives me full-screen x11 (but not actually full-screen with a root window) and a bunch of xterms in one screen, full-screen firefox in another, and then other mac applications in the rest.

i am also a heavy gimp user, but the attempts to port gimp to mac as a non-x11 app don't work very well at all. since i'm using fink, installing the regular x11 gimp was as easy as fink install gimp2, but using gimp with ratpoison has never been fun.

i wrote a small script many years back that provided an "mdi" of sorts for gimp, which basically ran Xnest^1^, then fvwm or something on that virtual display, and then gimp inside of it. that let ratpoison manage one Xnest window, while allowing a normal window manager to deal with all of gimp's windows inside of Xnest. however, Xnest doesn't seem to work too well on mac os, but since X11 is just a program on top of quartz, it's easy to run a second one and use the normal quartz-wm.

with the help of this xquartz faq, it's as easy as:

  1. make a copy the bundle in Utilities and call it something else, like
  2. right click on it, "show package contents", and double-click on the Info.plist file inside Contents.
  3. change the CFBundleIdentifier parameter from org.x.X11 to something unique like org.x.X11.gimp. this lets it run along side the normal and have its own set of preferences.
  4. edit your ~/.xinitrc file and call a different window manager depending on the X11_PREFS_DOMAIN environment variable. while this second server will startup and create a DISPLAY variable of the next available number (usually :1.0), it's best not to rely on that and use X11_PREFS_DOMAIN instead. my ~/.xinitrc now looks like:

    if [ $X11_PREFS_DOMAIN == "org.x.X11.gimp" ]; then
            (sleep 1; /sw/bin/gimp-2.6 &)
            exec quartz-wm
            exec /usr/local/bin/ratpoison

now i can just run X11Gimp and gimp starts up in its own x server in its own space (by adding X11Gimp in the spaces system preferences as being forced to a specific workspace). also, since this new server has its own set of preferences, its Applications menu is different than the normal server's, so other applications can be added to the menu that should be run as mac os-like windows, like wireshark.

1. handy openbsd tip: if you're ever hooking your laptop up to a projector to give a presentation with magicpoint but your laptop/x11 won't adjust to the smaller screen resolution of the projector, leaving magicpoint displaying off the sides of the cropped projector screen, run Xnest -geometry 800x600+0+0 :1 (or whatever fits the projector) and run magicpoint on :1. it'll look full-screen on the projector and you'll just see the rest of your desktop around it on your laptop screen. this idea came to me at nycbsdcon last year when kurt's laptop was acting weird.

Comments? Contact me via Twitter or e-mail.