9.1 X11

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 Linux

Because 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 side

9.1.1 Installing X11

Apple'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 X11

Launch 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 figs/command.gif -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 clients

X11 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:


An X11 bitmap (.xbm) editor.


An OpenGL 3D graphics demonstration. OpenGL applications running under Apple's X11 implementation have the benefit of full 3D hardware acceleration.


Displays information about OpenGL capabilities.


An X11 clock.


A calculator program that runs under X11.


A pair of eyeballs that follows your mouse cursor.


Gives another computer permission to open windows on your display.


Changes your cursor to the "cursor of doom." Any X11 window you click in will be shut down. If you change your mind and don't want to kill an app, press Control-C. This will not kill any Aqua application; it works only on X11 applications.


Displays the CPU load.

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:

Cutting and pasting

If you press figs/command.gif -C while you've selected something in an X11 window, you can paste it into another Mac OS X application. But that's where the similarity ends: to paste something into an X11 window, you can't use figs/command.gif -V. Instead, use Option-Click. If you have a three-button mouse, press the middle button to paste into an X11 window.

X11 application menus

The menu at the top of the screen always belongs to X11 itself. Individual X11 applications may have their own menu near the top of their main window. Figure 9-4 shows two different types of X11 application menus, a classic X11 menu from xmh (X11 mail reader) and a more modern X11 menu from gataxx (a game from the GNOME desktop system).

Figure 9-4. Comparing X11 menu styles

Be careful with figs/command.gif -Q

If you press figs/command.gif -Q (quit) while running an X11 application, this will attempt to shut down all of X11. Because of this, you'll get a warning if you try to do this when there are X11 clients running. Look for a quit option on the X11 application's own menu, or click the close button on its window.

Scrolling the xterm

By default, the xterm doesn't have scrollbars. However, like the Terminal, you can use a keystroke to scroll up and down, though, unfortunately , it's not the same keystroke: Terminal uses Page Up and Page Down, while xterm expects Shift-Page Up and Shift-Page Down.

Launching applications from the xterm

When you type the name of an X11 program in the xterm, it will launch, but the xterm window will appear to hang because it is waiting for the program to exit. To avoid this problem, you can either append the & character after the program name (to put it in the background) or press Control-Z after the program starts, and type bg to put the program in the background. See Figure 9-5 for an example of launching xeyes both ways.

You can also use the open-x11 command from within an xterm or the Mac OS X Terminal to launch an X11 application, as in open-x11 xterm .

X11, .bashrc, and .profile

If you've customized your Unix shell by editing ~/.profile , applications that run under X11, including xterm, won't respect the settings in that file. To correct this problem, put any essential settings in your ~/.bashrc file, which X11 will read. For more information, see the Apple X11 FAQ, which you can find by searching for "X11 FAQ" at http://developer.apple.com/qa/.

Figure 9-5. Launching X11 applications from the xterm

9.1.3 Customizing the Applications Menu

You 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.

Although the Application Menu item for xterm is named Terminal, it's not the same as the Mac OS X Terminal application.

Figure 9-6. Configuring xterm to launch with a different font

You can also specify a shortcut in the shortcut column. The shortcut key must be used with the Command ( figs/command.gif ) key, so the n in the Terminal/xterm entry specifies the figs/command.gif -N keystroke.

9.1.4 OpenOffice.org

OpenOffice.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:

  1. Download the installer (http://porting.openoffice.org/mac/) for OpenOffice.org. It is quite large (over 100 MB), so be patient.

  2. Double-click the installer and follow the prompts. You will need to accept the license terms, consult a README file, and select installation options (the default selections are fine). The OpenOffice.org installer launches a couple of other installers , each of which will ask you for your password. During the installation, you may get a warning that "XDarwin does not exist in the Applications directory." This tells you that OpenOffice.org could not find the X11 installation it expected to find (XDarwin is another distribution of X11 for Mac OS X). However, OpenOffice.org will work fine with Apple's X11.

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 Mac

If 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).

These instructions apply only to X11 applications that are installed on your Mac. If you want a complete remote desktop solution, see Share My Desktop (http://www.bombich.com/software/smd.html). You'll be able to remotely control your Mac from any system for which you can get a VNC (Virtual Network Computer) client, including Windows, Unix, Palm, Pocket PC, cell phones, and more. See http://www.realvnc.com/ for more information about VNC.

To set up your Mac for remote X11 access:

  1. Use the command sudo cp /etc/sshd_config /etc/sshd_config.backup to make a backup of the configuration file you'll edit in the next step. If anything goes wrong during this process, you can use the command sudo cp /etc/sshd_config.backup /etc/sshd_config to restore the original file and restart your Mac.

  2. Use the command sudo vi /etc/sshd_config to edit your remote login configuration file. Find the line that reads #X11Forwarding no . The leading # tells sshd to ignore that line in the file, and to use the default value instead. To be absolutely sure that remote X11 access is enabled, regardless of the default, remove the comment character (the "#"), and change no to yes . So, change this line to read X11Forwarding yes , and save the file.

  3. Open System Preferences Sharing and find the Remote Login setting. If it's disabled, enable it. If it's enabled, stop it and start it again to be sure that the configuration change you made in the previous step takes effect.

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@ 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 settings

To run X11 applications on your Mac and display them on another computer, take the following steps:

  1. Log in to the remote machine. If it's a Mac, start X11 and bring the xterm window to the front or launch a new xterm from the Applications menu. If it's a Unix or Linux system, start X11 (many systems start it automatically), and open an xterm or other terminal application, such as dtterm.

  2. On the remote machine, use ssh +x hostname (SSH Communications Security) or ssh -X hostname (OpenSSH) to connect to your Macintosh.

  3. After you've logged in to your Mac over SSH, run the X11 application that you're interested in.

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 X11
figs/lux3_0909.gif Opening a private network

If 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 Computers

You can also run X11 applications on other computers and display them on your Mac once you have X11 running. To do this:

  1. Log in to your Mac, start X11 (Applications Utilities X11), and launch an xterm.

  2. Issue the command ssh -X hostname , where hostname is the name or IP address of the remote computer.

  3. After you've logged in to the remote machine, run the X11 application that you're interested in. Figure 9-10 shows Netscape running on a Solaris system, but displayed on a Macintosh via X11.

Figure 9-10. Running an application on Solaris, but displaying it on a Mac

Learning Unix for Mac OS X Panther
Learning Unix for Mac OS X Panther
ISBN: 0596006179
EAN: 2147483647
Year: 2003
Pages: 88

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net