Running X11 - 4. Starting X11
4.1 Darwin
On pure Darwin, XFree86 behaves like on any other Unix.
The usual way to start it is via startx from the console;
that starts both the server and some initial clients like the window
manager and a terminal emulator with a shell.
On pure Darwin it is not necessary to specify any parameters, so you
can just type:
startx
You can customize what is started through several files in your home
directory.
.xinitrc controls what clients get started.
.xserverrc controls server options and may even
start a different server.
If you're having trouble (as in, you only get a blank screen or
XFree86 drops you right back to the console), you can start
troubleshooting by moving these files out of the way.
When startx doesn't find these files, it will use safe
defaults that should always work.
Alternatively, you can start the server directly with one of the XDMCP options, like this:
X -query remotehost
Details about this can be found in the Xserver manual
page.
Finally, there is the option to set up xdm; read its
manual page for details.
Note: If you're running Mac OS X anterior to Panther, you can type >console
at the login window and you'll get a text console that is
equivalent to pure Darwin.
In case you don't see a field to enter a user's name in the login window, just type the first letter of whichever user's name, following by option-return.
You can use all of the start methods outlined above, with the
exception of xdm.
Note: If you are running Mac OS X Panther or later, you cannot start XFree86 from the console window.
4.2 Mac OS X + XFree86 4.x.y
There are basically two ways to start XFree86 under Mac OS X.
One is double-clicking the XDarwin.app application in your
Applications folder. This will let you choose between full
screen and rootless mode in a dialog at startup. You can disable
the dialog and set XDarwin always to use the mode of your
choice in the Preferences dialog.
Prior to 4.2.0 it would fire up fullscreen mode automatically, and there was no way to get rootless mode by double-clicking the application.
The other way to start XFree86 under Mac OS X is via
startx from Terminal.app.
If you start the server this way, you must tell it that it should run
in parallel with Quartz.
You do this by passing the -fullscreen option, like this:
startx -- -fullscreen
That will start up the server in fullscreen mode,
plus the clients in your .xinitrc.
NOTE: prior to 4.2, -quartz was used for fullscreen mode.
You can start it in rootless mode with the
-rootless option:
startx -- -rootless
The -quartz option no longer selects fullscreen mode,
but rather uses the default mode set in the preferences.
As of version 4.3, if you use startx without arguments, the startup dialog box will come up.
4.3 Starting X.org
X.org works identically to XFree86 in all respects.
4.4 Starting Apple's X11
Functionally, Apple's X11 works similarly to XFree86 (e.g. using a .xinitrc file to control the clients that are launched on startup). The normal way to run it is by double-clicking the X11.app icon (whose default location is /Applications/Utilities). You can use startx, as well, but it doesn't have a commmand-line option to set the display mode; X11.app will start up in whatever mode was previously set in its Preferences.
If you don't set up a different window manager you will be running Apple's quartz-wm window manager. X11.app's Preferences give the option to switch between fullscreen and rootless modes without restarting. However, this doesn't work for quartz-wm; it is necessary to choose a different window manager (e.g. in .xinitrc)
4.5 The applex11tools package
Fink's applex11tools package allows the use of X11.app and quartz-wm under OS 10.3 and later with XFree86 4.4 or later or X.org.
To install this package you must enable the unstable tree, and have X11User.pkg somewhere within /Users or /Volumes. X11.app will be installed in the Applications folder within your Fink tree. You can now use either X11.app or XDarwin.app.
4.6 The .xinitrc File
If a file named .xinitrc exists in your home
directory, it will be used to start some initial X clients, e.g. the
window manager and some xterms or a desktop environment like GNOME.
The .xinitrc file is a shell script that contains
the commands to do this.
It is not necessary to put the usual #!/bin/sh
in the first line and to set the executable bit on the file;
xinit will still know how to run it through a shell.
When there is no .xinitrc file in your home
directory, X11 will use its default file,
/private/etc/X11/xinit/xinitrc.
You can use the default file as a starting point for your own
.xinitrc:
cp /private/etc/X11/xinit/xinitrc ~/.xinitrc
If you're using Fink, you should source init.sh right at the beginning to make sure the environment is set up correctly.
You can put fairly arbitrary commands in an .xinitrc,
but there are some caveats.
First, the shell that interprets the file will by default wait for
every program to finish before it starts the next one.
If you want several programs to run in parallel, you must tell the
shell to put them "in the background" by adding a & at
the end of the line.
Second, xinit waits for the .xinitrc
script to finish and interprets that as "the session has ended, I should
kill the X server now, too".
This means that the last command of your .xinitrc
must not be run in the background and it should be a long-living program.
Customarily, the window manager is used for this purpose.
In fact, most window managers assume that xinit is
waiting for them to finish and use this to make the "Log out" entry in
their menus work.
(Note: To save some memory and CPU cycles, you can put an
exec before the last line like in the examples below.)
A simple example that starts up GNOME on XFree86 or Xorg:
. /sw/bin/init.sh exec gnome-session
A more complex example for bash users that turns the X11 bell off, starts some clients and finally executes the Enlightenment window manager:
. /sw/bin/init.sh xset b off xclock -geometry -0+0 & xterm & xterm & exec enlightenment
To start GNOME 2.4 and later under Apple's X11:
. /sw/bin/init.sh quartz-wm --only-proxy & exec gnome-session
To start KDE 3.2 (version < 3.2.2-21) under Apple's X11
. /sw/bin/init.sh export KDEWM=kwin quartz-wm --only-proxy & /sw/bin/startkde >/tmp/kde.log 2>&1
And finally to start the latest unstable version of KDE under Apple's X11:
. /sw/bin/init.sh /sw/bin/startkde >/tmp/kde.log 2>&1
4.7 OroborOSX
OroborOSX is an alternative to the X11.app and XDarwin display servers. It requires a preexisting X11 installation to work. X11.app or XDarwin.app continue to function, as well
When run, OroborOSX starts its own rootless-only window manager, and doesn't read in either the system's xinitrc or user's .xinitrc files. After starting, it does have a menu option to execute .xinitrc. However, it does have its own method to set up applications to run when it starts.
It also provides a mechanism to start X11 applications from the Finder via startup scripts.
For more information visit the OroborOSX homepage.
Next: 5. Xtools