The X Window System (commonly called X11 for short, reflecting that the current version is 11), is the standard graphical user interface for Unix systems. Mac OS X is a significant exception, as was its predecessor, NeXTStep. On Mac OS X, the Quartz Compositor is responsible for drawing what appears on your screen. In an X11-based system, an application called an X server handles this. The programs that run under X11, such as office applications, web browsers, and terminal windows , are X clients . X servers and clients talk to each other using Unix networking: if an X11 word processor needs to pop up a dialog asking whether you want to save a document, it makes a network connection to the X server and asks it to draw that window. Because X11 is networked in this way, you can run an X client on a machine across the office or across the planet, and have it display on your computer's X server. X servers are typically full-screen applications that completely take over the display. Figure 9-1 shows a fullscreen X server running on a Linux computer. Three applications are running: an xterm (which is similar to the Mac OS X Terminal), a meter that shows how busy the Linux computer's CPU is, and a similar meter that's running on a Solaris system nearly one hundred miles away, measuring the system load on that box. In addition, a menu is visible. This belongs to the window manager , an X11 program that takes care of putting frames and window controls (such as close, resize, and zoom) around application windows. The window manager provides the overall look and feel, and also lets you launch applications and log out of X11. X11 users have many windows managers to choose from; the one shown in Figure 9-1 is icewm . Figure 9-1. An X server running on LinuxBecause X11 behaves very differently from Quartz, Apple's solution was to ship a rootless X server, which is an X server that does not take over the screen. Apple's X11 implementation, which includes the X server, many common X clients, and a software development kit for writing X11 applications, is derived from XFree86 (http://www.xfree86.org), the X11 release used on Linux, FreeBSD, NetBSD, OpenBSD, and many other operating systems. Apple also created an X11 window manager, quartz-wm , which draws X11 windows that look and behave much like Quartz windows. As you can see, the X11 xterm and Mac OS X Terminal shown in Figure 9-2 look remarkably similar. Figure 9-2. Examining an xterm and Mac OS X Terminal side by side9.1.1 Installing X11Apple's X11 is included with Mac OS X 10.3 Panther, but it is not installed by default. To locate the X11 installer, use the Finder to look for a file named X11User.pkg on the Mac OS X installation CD-ROMs. If you are using an earlier version of Mac OS X, or if you have trouble finding this file, visit http://www.apple.com/macosx/x11/ for the latest information. Double-click the Mac OS X installer to start it, and install it on your Mac, following the prompts. When the installer is finished, you'll have an application called X11 in /Applications/Utilities . 9.1.2 Using X11Launch the X11 application by opening /Applications/Utilities in the Finder and double-clicking on the X11 icon. After a few seconds, an xterm window will appear. You can start a new xterm by selecting File New Window (or using -N). Click the Applications menu to see a list of shortcuts. By default, there are options for Terminal (starts a new xterm), xman (lets you browse Unix manpages), and xclock (displays a clock on the screen). Figure 9-3 shows X11 running along with these three applications. Figure 9-3. Running some X11 clientsX11 includes many other applications. To see a list, examine the X11 application directory with the command ls /usr/X11R6/bin . Here are a few of the most interesting utilities included with Mac OS X:
There are some significant differences between X11 and the Mac OS X interface that you need to watch out for. Although Apple's X11 does a great job of minimizing these differences, there are still some quirks that may throw you off:
Figure 9-4. Comparing X11 menu styles
Figure 9-5. Launching X11 applications from the xterm9.1.3 Customizing the Applications MenuYou can customize X11's Applications menu by selecting Applications Customize. Click Add Item to insert a new item. Specify the menu title in the Name column, and use the Command column for the command to execute. You can also add any necessary parameters or switches here. For example, to change the Terminal/xterm menu item so it uses a 12-point antialiased Monaco font, add the switches -fa Monaco -fs 12 , as shown in Figure 9-6.
Figure 9-6. Configuring xterm to launch with a different fontYou can also specify a shortcut in the shortcut column. The shortcut key must be used with the Command ( ) key, so the n in the Terminal/xterm entry specifies the -N keystroke. 9.1.4 OpenOffice.orgOpenOffice.org is a free office suite that stands up remarkably well in a head-to-head comparison to Microsoft Office. It started life as StarOffice, and its owner, Sun Microsystems, continues to market it under that brand name (http://www.sun.com/staroffice). However, Sun has released the source code to most of StarOffice, and from that massive collection of source, the OpenOffice.org project was born. OpenOffice.org is available in Windows and Unix (X11) versions. As of this writing, it does not have native support for Mac OS X. So, if you want to use this suite on Mac OS X, you'll need to run it under X11. However, an effort is underway to make OpenOffice.org a full-fledged Aqua application (see http://porting.openoffice.org/mac/timeline.html). To install OpenOffice.org on your Mac:
After you've installed OpenOffice.org, you can launch it by double-clicking Start OpenOffice.org , which is located in /Applications/OpenOffice.org1.0.3 (the last few numbers of that folder name may vary depending on which version of OpenOffice.org you have). The first time you launch this program, you'll be asked for the location of your X11 installation. Click Browse and select /Applications/Utilities/X11 . The OpenOffice.org word processor will appear, and you can select File Open to open an existing document, or start typing to create a new one. Figure 9-7 shows the Microsoft Word document for the text of this chapter. Select File New to create a spreadsheet, drawing, or presentation application. Figure 9-7. Editing a Microsoft Word document in OpenOffice.org.You can also launch OpenOffice.org from within an xterm or Terminal with the following command: open-x11 /Applications/OpenOffice.org1.0.3/program/soffice Although OpenOffice.org does not use the full power of Mac OS X's Aqua GUI, it's one of the snazzier X11 applications out there. Also, it offers near-complete compatibility with Microsoft's Word, Excel, and PowerPoint. So although it's not perfect, the price is right, and it may be just what you need if you have to work with Microsoft Office formats but don't want to purchase the product. 9.1.5 Remote X11 Access to Your MacIf you use other Unix systems that run X11, you can log in remotely to your Mac, run X11 applications, and have them display on that Unix system (the applications are still executing on the Mac, but they appear on the Unix system). If you have an always-on broadband connection, you can even do this from afar (perhaps you use a Unix system at school or at work, but want to connect to your Mac at home).
To set up your Mac for remote X11 access:
Pay attention to the instructions at the bottom of the Sharing preference pane (you need to have Remote Login selected for these to appear). This will tell you how to connect to your computer remotely. In Figure 9-8, it specifies the command ssh bjepson@192.168.254.104 for connecting to Brian's computer. This command (with some changes; you'll have a different user name and IP address) will let you run X11 applications on your Mac and display them on other Mac OS X systems on the same network as your Mac. It will also work with any Unix system on the same network as your Mac that has either the commercial version of SSH from SSH Communications Security (http://www.ssh.com/) or the open source version (the version that Mac OS X uses) from http://www.openssh.org/. Figure 9-8. Examining the Remote Login settingsTo run X11 applications on your Mac and display them on another computer, take the following steps:
Figure 9-9 shows an example of connecting from a Solaris system and launching OpenOffice on the Macintosh (but it appears on the Solaris system instead of the Macintosh). Figure 9-9. OpenOffice.org running on a Mac, but displayed on a Solaris system using remote X119.1.5.1 Opening a private networkIf your Macintosh is on a private network and you try to connect from the outside, the command shown in the Sharing pane will probably fail, since private network addresses are not reachable from other networks on the Internet. If you use an AirPort base station or a non-Apple access point or router to connect your home network to a broadband connection, then you are almost certainly on a private network. However, you can use the Port Mapping tab of the AirPort Admin Utility (located in /Applications/Utilities ) to open a connection on port 22 (the port that SSH uses) and forward it to your Mac. When you issue the ssh command from a remote machine, you'll need to replace the IP address shown in Sharing preferences to that of your AirPort base station (see the Internet tab of the Airport Admin Utility). Even with this configuration, remote access may not work, since some Internet Service Providers (ISPs) place restrictions on inbound connections. 9.1.6 X11 Access to Other ComputersYou can also run X11 applications on other computers and display them on your Mac once you have X11 running. To do this:
Figure 9-10. Running an application on Solaris, but displaying it on a Mac |