Using XDarwin with Apple's X11

Mar 03, '03 09:20:00AM

Contributed by: diamondsw

Okay, it took a few weeks of work, but I managed to get XDarwin to work with Apple's X11 installation. Why? Well XDarwin can run full screen (which is useful), and it also runs from >console (which is just cool). Be warned, this is NOT easy, since it is extremely hard to get the XDarwinStartup and XDarwin server files without installing all of XFree86 (which Apple's X11 already provided).

[robg adds: I'm not even going to claim that I'm thinking about trying this one -- you're on your own from here on out. If you do try, please post a comment regarding the outcome of your experiment...]

Instructions:

  1. Install XDarwin.app, /usr -> X11R6 -> bin -> XDarwin, and /usr -> X11R6 -> bin -> XDarwinStartup. This is the most difficult part, and may require manually extracting them from binary installers. Not fun at all, and I encourage the XDarwin group to create an installer to automate this. I'd create an install package for this myself, but I doubt it's legal.

  2. Create a symbolic link from /usr -> X11R6 -> bin -> XDarwinQuartz to XDarwin.app -> Contents -> MacOS -> XDarwin.

  3. Copy /usr -> X11R6 -> bin -> startx to /usr -> X11R6 -> bin -> StartXDarwin

  4. Using a text editor, open StartXDarwin and change:
     defaultserver=/usr/X11R6/bin/X
    to
     defaultserver=/usr/X11R6/bin/XDarwinStartup
  5. Add the following lines to .tcshrc (may need to be modified for other shells):
    # Set the display variable - critical for running from >console mode
    if (! $?DISPLAY) setenv DISPLAY :0.0
    # Create some optional aliases to make it a bit easier to start XDarwin
    alias StartXDarwin StartXDarwin -- -fakebuttons
    alias StartXDarwinQuartz StartXDarwin -- -fakebuttons -quartz
  6. Open the terminal and run the command rehash; this will force the shell to rebuild its list of available commands.

  7. Create a ~/.xinitrc similar to the following - this will allow you to access fink-installed programs without the full path (if you need it), and will allow you to select different programs or and window managers based on what X11 environment you're using.
    #!/bin/sh
    
    # set up the fink path
    if [ -f /sw/bin/init.sh ]; then source /sw/bin/init.sh; fi
    
    # set up the X11 paths
    userresources=$HOME/.Xresources
    usermodmap=$HOME/.Xmodmap
    sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
    sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap
    
    # merge in defaults and keymaps
    if [ -f $sysresources ]; then xrdb -merge $sysresources; fi
    if [ -f $sysmodmap ]; then xmodmap $sysmodmap; fi
    if [ -f $userresources ]; then xrdb -merge $userresources; fi
    if [ -f $usermodmap ]; then xmodmap $usermodmap; fi
    
    # correct for locale problems
    unset LANG
    
    # Start the proper window manager and programs
    
    # Find out if X11 is running at all
    x11pid=$(cat /tmp/.X0-lock)
    if [ $x11pid -ne 0 ] ; then
      # Determine if "XDarwin" is running
      isXDarwin="`ps -x -o command | grep XDarwin | grep -v grep | wc -l`"
      if [ $isXDarwin -ne 0 ] ; then
        twm &
        xterm -geometry 120x54+10+10
      fi
      # Determine if "X11.app" is running
      isApple="`ps -x -o command | grep X11.app | grep -v grep | wc -l`"
      if [ $isApple -ne 0 ] ; then
        quartz-wm &
        xterm -geometry 120x54+10+30 -fa Monaco -fs 10
      fi
    fi
That's it!

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030226225800895