Based on the feedback I received from my overview of X on X, I thought I'd tackle how to install rootless X Server.
The term "rootless X Server" can be misleading. In this case, "root" doesn't refer to "super-user" as it is often used. Its meaning in this article is that you can run a program with an X Windows interface directly over the desktop in Mac OS X without the application being tied to the computer's original desktop (in other words, Aqua). It runs "rootless."
Rootless X Server is available right now. The folks at MacGimp.org are selling binaries of XFree86 4.0.3 with a patch to make it run rootless. Rootless X Server broke in the latest version because of some changes in other areas of the code, and work hasn't finished to get it going again. I checked the project status on Sourceforge.net, and the task to finish the rootless X Server shows it is 85 percent done. But I'm not sure how accurate that status is. I do know that rootless X Server didn't make it into the latest release of XFree86 4.1.0.
While reading the X on X forums, I came across a recent patch to XFree86 4.1.0 that re-implements rootless functionality. I debated applying that patch and compiling XFree86 from source. According to the message accompanying the patch, it reverts back to the previous versions of some code in order to work around the stuff that broke the previous rootless X Server patch. I also noticed a message that suggested compiling the current CVS source for XFree86 and starting X with the
-rootless option. CVS sounds like the way I'd like to start.
The easiest way to obtain XFree86 is to download the precompiled binaries for your OS. However, binaries are only available when a new release comes out. To get the most up-to-date code, we need to use CVS. CVS is a tool for managing source code and is used by a lot of open-source projects. CVS is already installed on Mac OS X.
Getting the code via CVS is quite easy and if the download gets cut off, it will restart right where it left off.
Instructions on how to obtain XFree86 through CVS are located on the XFree86 CVS web page. It lists several ways that you can get the code. I'll show you the easiest way.
Open up a terminal window and type this:
cvs -d :pserver:firstname.lastname@example.org:/cvs login
This will ask you for a password, which is
anoncvs. That logs us into the CVS
pserver and from there we can execute regular CVS commands. To get the code, we want to use
cvs -d :pserver:email@example.com:/cvs checkout xc
The default window manager for this install of rootless X on X is less than perfect. Have you tested other window managers with this configuration?
The above command will start a large download process that will place several thousand files and directories on your hard drive. This is the source code for XFree86, and depending on your connection speed, the download may take a while.
I was downloading via a modem and got disconnected several times. After more than two days of trying to download, I finally had all the files. I did a
du -ks xc and found out that I was the proud owner of 300MBs of source code.
The next step was to compile all the code I just downloaded.
cd xc make World > world.log & tail -f world.log
The build process took several hours on my tangerine iBook, and in the end I had 520MBs of files, including the source code. The next step was to install what I had just compiled.
sudo make install > install.log & password: tail -f install.log
By preceding the command with
sudo, we invoke our rootly powers. You'll be asked for your password. When you type it, it won't echo to the screen, so you won't see what you've entered.
It installed over my old copy of XFree86 4.1.0 without any problems. Aside from taking a long time, the process was very painless.
After it installed, I thought I would click the XDarwin icon to see if anything different happened. I was greeted with a menu that asked if I wanted to start XFree86 in full-screen mode or rootless.
I clicked on Rootless and it proceeded to load X right on top of all my windows. I hadn't configured anything yet, so it loaded
twm as the window manager. The default configuration loads three xterm windows and an xclock. It appears the default settings are optimized to work with a screen resolution of 1024 x 768 or higher. Because my iBook is only capable of 800 x 600, my desktop looked like the image below.
The first thing I noticed was that the top menu bar was covering the uppermost part of the window preventing me from grabbing and moving it. The window was also cut off at the bottom so I couldn't resize it. By pressing
command+option+a, I was able to toggle the menu bar on and off. The bottom dock also disappeared at the same time. That let me get to my window and move it, but the entire process was somewhat annoying.
I then created a
.xinitrc file in my home directory.
vi ~/.xinitrc xterm & xterm & twm
I added the commands to start the window manager,
twm, plus a couple of xterm windows.
When I restarted X this time, it didn't appear as though anything happened. However, when I pressed
command+option+a, it revealed that the xterms had started minimized and were hidden under the menu bar.
You can pass parameters to xterm that tell it how to look when it starts. So I changed the xterm line to read:
xterm -geometry 80x20+94-50 &
Now I get a much more reasonable sized window when I start X.
The next thing I changed was the XDarwin preferences. The preferences allow you to set the startup default to rootless, change the toggle key sequence, and tweak a few other knobs. I set mine to start rootless by default, without being prompted every time.
Here are a few other handy tips I picked up.
To quit X, just select it from the menu item. You can also click and hold on the dock icon and select quit from there.
If you highlight something in an X window, it immediately becomes available to the buffer so that you can paste it into an Aqua window using
command+v. If you want to paste in an X window, use
If you close all your xterm windows, you can start one from a terminal window. Actually, you can start any X program from a terminal window. However, it won't be able to open the display unless you set the display environment variable or implicitly tell it which display to "connect to." The display number is 0 (zero) and is configurable in the XDarwin preferences. To start an xterm from an Aqua terminal try this:
xterm -geometry 80x20+94-50 -display :0.0
That should be enough to get you going with rootless X on X. I really dislike the default window manager and will be experimenting with others. If you know of a good window manager for rootless X on X, let me know and I will review a few of them in my next article.
After writing this article, I found that the X on X project has released a binary patch for XFree86 4.1.0 that will allow a rootless X server. The patch is based on a CVS checkout from about the same time I was compiling my copy, so you should get the same results.
Chris Coleman is the Open Source Editor for the O'Reilly Network and is actively involved with community projects such as OpenPackages.org and Daemon News.
Read more Mac Dev News Roundup columns.
Return to the Mac DevCenter.
Copyright © 2009 O'Reilly Media, Inc.