BMT Micro - Registration site for the best OS/2 shareware applications available. (click here).Improve OS/2's performance with Priority Master II (click here)
Installing XFree86 in OS/2 - by Chris Wenham
OS/2 e-Zine!

Go to a Printer Friendly version of this page

Chris Wenham is the Editor-In-Chief of OS/2 e-Zine! -- a promotion from Senior Editor which means he now takes all the blame.

Related Articles
OS/2 and X Window
OS/2's Hidden Treasure

Blast Back! Send a private message directly to Chris Wenham with your thoughts:

Contact OS/2 e-Zine!

Sponsored links:
The OS/2 Supersite

Summary: What can you do in half an hour that instantly adds access to a staggering new array of software in OS/2? Install XFree86, that's what. This is a free X Window server that isn't actually that hard to install and configure.

There's a good reason to get some kind of X Window server onto your OS/2 system today: Software. Lots of it. A large number of applications born on Unix have been ported to OS/2 thanks to the work of Eberhard Mattes (for EMX) and Holger Veit (XFree86 for OS/2). EMX filled in many of the "gaps" in OS/2 that Unix programs were written to expect, instantly opening the gates for a flood of mostly character mode and command line utilities that either stayed that way, or gained PM (Presentation Manager) front ends. Later, building on what EMX had laid, XFree86 came along and opened another set of gates - this time for graphical Unix software. What's available right now, and what's only a compile away, is a huge number of software titles.

Now even though a couple of XFree tutorials have popped up on the web recently (such as in the VOICE Newsletter for February), we decided to risk accusations of unoriginality and produce one of our own. Since we'll be discussing X applications in more detail in the coming months we felt it'd be appropriate to introduce our readers to it in this way.

But before we install XFree we should first describe what it is. Developed in the mid 80s, the X Window system (or 'X' for short) was the Unix answer to the windowing systems that were appearing on Macs, Amigas and DOS PCs. But X, coming from a Unix heritage, embodied an important part of the Unix philosophy; the machine on which the program ran might not necessarily be the same machine that it's being controlled from. So while a Windows program expects its menus and buttons and pictures to be displayed on the screen plugged into the computer it's running on, an equivalent X program could be running on a machine in New York but have its display seen and manipulated on a screen connected to a computer in San Francisco. To X, it doesn't matter. Both the program and its display could even be on the same machine - just like it is with Windows and OS/2's Presentation Manager.

It should be noted that X uses a funny reversal of the terms "client" and "server". Under typical circumstances, the program you're controlling might be on a machine that you call a "server", controlled from a desktop PC or terminal that you call a "client". But as far as X is concerned the PC/Terminal is running an "X server" (serving an X GUI to the program) and the server machine is running an "X client" (a program making use of the X server). It's daft to us, but that's the way its terminology goes.

Since X has its own API (Application Programming Interface), it's necessary to install an X Window server to run X Window applications and for OS/2 there are at least three or four that you can choose from. There's Exceed from Hummingbird communications, a commercial implementation that supports some extra frills such as seamless integration with the OS/2 desktop. PMX from IBM, sadly discontinued. And XFree, which as its name implies, is free software. XFree doesn't have as many frills as Exceed does, there's no seamless OS/2 desktop integration (so you have to run it fullscreen all the time), and no Clipboard sharing built into it. There's a program you can download that will attempt to run X on the OS/2 desktop, using DIVE, but we were unable to make it work. Plus there's another utility that will share OS/2's clipboard with the one in X, not quite fully though.

But despite XFree needing to run in a full-screen session, it's still possible to run it alongside your regular PM / Workplace Shell desktop, switching between the two with the window list and ALT-Escape. And despite all the rah-rah about X's networking support, you don't actually need two machines to use an X Window application. X will simply communicate with the program through a named pipe, or a loopback interface.

Installing XFree

Even though Unix software has a reputation for being arcane, XFree for OS/2 is easy to install. The basic steps are to download a couple of base files, run a program that helps you identify your video card and what driver you should use, download that driver and whatever remaining optional files you want, then run a program that asks you a few questions and configures X Windows for you.

In more detail, the steps are as follows:

1: Download the base files

From the FTP site, in the directory for the OS/2 port, you need to grab and, saving both of them to your C:\ directory (or the root directory of any other drive if you prefer) when your browser or FTP client asks where to put them. Skip the emxrt package if you've already installed a recent version of EMX.

Once downloaded, open an OS/2 Window (command line) and from that root directory unzip the packages, probably typing "unzip *.zip" if you have InfoZip installed, or "pkunzip *.zip -d" if you have PKZip. You need to make sure the directory structures will be unpacked as well, something that isn't usually a default option with PK Zip. You'll notice it'll be creating and unpacking to a directory called "Xfree86" and "emx".

Among the files it will have unpacked will be a device driver called xf86sup.sys. This adds some more functions that X needs and must be loaded from your CONFIG.SYS, so it's about this time we'll add that and a couple of other values that should be in there - reducing the number of reboots we need to only one before XFree can be run. Opening the config.sys into a text editor, add this somewhere at the bottom:


A few other lines that would be handy at this point are:

SET TERMCAP=C:/XFree86/lib/etc/emx.termcap.X11
SET HOME=C:\home
SET DISPLAY=localhost:0.0

You'll want to change the references to "C:" if you're installing this to another drive letter, of course. Lastly, make sure the following is in your LIBPATH:


And that this is somewhere in your regular PATH:


The above lines add: A terminal emulation mode (ansi), a home directory (make sure you create this before you run X), the root drive of where XFree can find the "XFree86" directory, and the location of the display ("localhost", a shortcut that always points to your machine).

A note about Localhost, you should go into the TCP/IP Configuration notebook in your OS/2 System Setup folder and make sure it's enabled and pointing to the address (the universal shortcut to your own machine). You'll find the settings on the first page in that notebook, under the item "loopback interface". It's through this that X will communicate with the programs you run under it. Without it, X won't work.

At about this point you'll need to reboot your computer, it'll be the only time you'll have to even though we'll be adding one more line to the CONFIG.SYS before it's all over.

2: Run Superprobe

Superprobe.exe, now found in the XFree86\bin directory of your hard drive, is a simple video card detection program. Most of the time it will correctly identify what video card you have, and if not, you can probably identify the right driver to use just by knowing who made your card and what approximate model it is. Run this in a full-screen OS/2 session and make a note of what it reports.

Since XFree itself also runs in a full-screen session it must have its own video drivers, it can't use OS/2's Presentation Manager drivers and there are no "seamless" drivers for XFree that we were able to get working (there's an "early alpha" of one that purports to use DIVE, but we failed to make it work). That's an inconvenience, but not a terrible one since you can still switch back and forth between the Workplace Shell and XFree by using the window list or any other task switching utility you prefer.

3: Download the Driver

Going back to the XFree FTP site you'll need to download the driver that corresponds to your video card. XFree has an odd way of grouping its video card support, some cards such as ATI and S3 based cards will have their own separate drivers, while Matrox, generic SuperVGA and others will be all combined into one general-purpose SVGA driver. Don't worry if the documentation calls the "SVGA" driver an 8-bit, or 256 color driver only, it'll support true-color displays (16 bit and higher) if your card does too. It will also support all the extra "accelerated" video features of advanced cards like the Matrox Millenium.

A note about the naming convention that's used on the FTP site. There are actually two sets of drivers, one set that begins with an 'S', and another that begins with 'X'. the 'S' set are smaller drivers that have a number of extra support features taken out. The 'X' drivers are the full-featured ones, with extra libraries compiled into them, some of which may be used by the programs you'll want to run after you have X working. Choose the 'X' ones for now, since the difference isn't that big.

Like with all of the other XFree distribution files, download this driver to the root directory of the partition or hard drive you're installing X on. Unzip them there and the files will be unpacked into the correct directories.

While you're at the FTP site you should also grab a few of the other required and optional packages too. XBIN.ZIP (remaining binaries), XDOC.ZIP (documentation) and XFNTS.ZIP (75 dpi fonts) are all required, but also think about getting XFSCL.ZIP (scalable Speedo and Type1 fonts) and XMAN.ZIP (manual pages, for documentation) too.

4: Configure XFree

With everything unzipped you should be able to find a program called xf86config.exe in the XFree86\bin directory. Run this and answer the questions it asks you about your system and preferences. Pay attention, especially the sections about video card "clock" chips. If, after you've picked your video card from its extensive list, it recommends NOT to probe for clock chips, it will still ask you if you want to do it anyway. Always go with the recommendation unless you think you have good reason not to. The philosophy that XFree is steeped in assumes that the user always knows what he/she is doing. So if you don't, just do exactly what it tells you ;-)

Other than just needing an alert operator, XF86config is easy enough to get through. It'll ask you what scan frequencies that your monitor can handle, so it's a good idea to check the monitor's manual beforehand to find out. If you've lost the manual, try something conservative (a narrow range that doesn't go above 90khz or so), and if it doesn't work you can always go back and run xf86config again. It's unlikely that you'll damage the monitor by trying to run it at a refresh rate higher than it can handle, but try to get as high as you can anyway. The higher the refresh rate, the easier it is on the eyes to stare at the screen.

The configuration file that it creates, called XF86Config, is a human-readable text file that you'll find in the Xfree86\lib\X11 directory. If you messed up somewhere and don't want to run the configuration program from scratch again, just load up this file in a text editor. It has enough comments embedded in it to help you understand its structure.

5: Run XFree

At about this time it should be safe to run XFree for the first time. X is started with the script "startx.cmd" that you'll find in the XFree86\bin directory. Open an OS/2 Full Screen session (or window, it'll jump to full-screen mode anyway) and change to this directory. But before you start XFree you'll need to type one extra line, one that you'll end up migrating into the CONFIG.SYS eventually, but for now can be typed here so you don't need to reboot:

SET XSERVER=C:/XFree86/bin/XF86_SVGA.exe

Look at that line carefully. First of all, like with the "SET TERMCAP" of earlier, we're using forward slashes (the Unix style directory name separator) and the XF86_SVGA.exe is refering to the video driver we downloaded earlier. If you're not using the SVGA server, change this to the one you are using. Once you're satisfied that it's correct, you can move it into your CONFIG.SYS, probably grouping it with the other XFree related settings.

Next, type "startx", and if all goes well you'll be looking at a properly configured XFree a few seconds later. If not, try running the "checkinstall.cmd" program from a command line (found in your XFree85\bin directory too), as its name implies, it will check how your computer is set up and will offer some hints if something is missing or wrong.

Minor Configuration Details - Resolution

There will remain a few issues of preference that you'll want to fix after X is installed and working. First of all, it'll start in some ridiculously small video mode by default, probably 640x480. To change this on the fly you hold down the CTRL and ALT keys, then hit the + or - key on the keyboard to cycle up or down through video modes. This is certainly handy if you want to zoom in on something, just press CTRL+ALT and the - (minus) key. But you'll probably want to change the settings so that X always starts in the video mode you want. This is how:

  1. Open the XF86Config file in the XFree86\lib\X11 directory with a text editor (like the OS/2 System Editor).
  2. Find the "Screen Sections", ignoring the "Monitor" and "Modeline" sections.
  3. Re-order the listing of screen resolutions in the various "Subsection Display" areas. There's a separate section for each color depth. So where the default line might look like this:

"640x480" "800x600" "1024x768" "1280x1024"

Your modified line could look like this:

"1280x1024" "1024x768" "800x600" "640x480"

Change these for each color depth level that you think you'll be working in.

Color Depth

By default, X will usually always start in 256 color mode too, which will be annoying if you like to do graphics editing work or dislike the dithering effects that will be applied at that depth. To bump it up to higher color depths (to the extent that your video card supports) you need to run the "startx" program with a command line switch that looks a bit like this:

startx -- -bpp 16

Notice the two dashes followed by a space and then another dash before the "bpp" part (which stands for "bits per pixel"). 256 color mode is 8 bits per pixel, 65 thousand color mode is 16 bits per pixel, and 16 million color mode is 24 bits per pixel. Be advised that the higher the color depth (bits per pixel), the more memory is used for any given resolution. A video card with only 2 megs of ram couldn't achieve more than 1024x768 in a 16 bit color depth, for example. A card with 4 megs of video ram should get up to 1280x1024 in 24 bit depth and higher.

The Window Manager

One other concept that X introduces is that of the Window Manager, a program which controls how everything appears outside each program's window. That is, it determines not only how the window frames and control buttons (close, minimize etc) look and behave, but it may also provide a mechanism for launching new programs and task switching them. Interesting is the fact that you can choose whatever Window Manager you like without disturbing the programs running, so you can switch between Window Managers without restarting.

The window manager that will run by default when you start up XFree86 for OS/2, TWM, is awful and ought to be replaced fast. Fortunately, while TWM is the default, XFree86 for OS/2 also comes with a better window manager called IceWM. This one mimics the OS/2 look and feel to some degree. No window manager yet matches the flexibility of the Workplace Shell.

To change the default TWM manager to IceWM you need to use a text editor to open the xinitrc.cmd file that you'll find in the Xfree86\lib\X11\xinit directory. Scroll down until you get almost to the very end, you'll see a line that looks like this:


Delete that, and in its place put:


When you restart X you'll have the new window manager. Sometimes it's possible to exit out of the window manager without exiting all the way out of X. If so, and you have an Xterm (X equivalent of a command line window, XFree will run the standard OS/2 command interpreter within one of these) open, you can launch another window manager next. You can't run two window managers at the same time, however.

Dvorak Keyboard Layouts

If you prefer to use the Dvorak keyboard layout (an alternative to QWERTY where the vowels are all on the home row and other keys are arranged to help speed up typing) you can add it to XFree very easily. Remember the HOME directory you set in the CONFIG.SYS earlier? Among other configuration files that various X (and even some Java and native OS/2) programs will put there, you can add some of your own. ".Xmodmap" (notice period at the beginning of the filename) is one that, when detected by the X startup program, will be used to reconfigure the X Windows keyboard layout. We chose to make our own Dvorak layout file that you can download to use yourself, but you may also find others available elsewhere on the net. After creating (or copying) this file in the HOME directory (usually something like C:\Home or C:\Home\YourName in OS/2, you'll have to create it yourself), the new layout will always take effect whenever you start X.

Multiple Users

Incidentally, it's about here that we could mention the multi-user nature of X and Unix. That HOME directory is needed because it's created as a matter of course on Unix systems. Every user on a computer will have his or her own home directory, and it's here that preference files are kept. While one user types QWERTY, another likes Dvorak, and if the keyboard layout file is stored in the home directory rather than some global one then it's easier to keep those preferences separate. Each user, with access to only his or her home directory, can edit these files without fear of stomping over anyone else's preferences.

So why mention this in an article about the OS/2 version? OS/2 Warp was designed with the assumption that there'd be only one user per machine (Workspace on Demand is the true multi-user version of OS/2). But remember that this HOME directory was provided with a SET command, a command that can be issued on the command line, without rebooting, and does not necessarily need to be in the CONFIG.SYS. So if you have more than one person using your computer it'd be possible to create a small batch file that overrides the default HOME and lists another one instead, establishing a psydo multi-user system. You could create a hierarchy of directories that look like this:


And create icons that change the HOME environment variable before starting X. Each user then has his or her own place to store their preferences, just like on a Unix system.

Launching and Switching Programs

And lastly, the method of launching and switching programs in X is going to differ from window manager to window manager, but the universal method of launching that will always work is to just type its name into an Xterm window. By default, XFree will launch at least one Xterm window, usually called "login" (the name is essentially meaningless on a single-user OS/2 machine, but that's the only difference between it and any other Xterm window that you might open). Since it's passing all of those commands through the standard CMD.EXE (OS/2 command processor) you can use any command line instruction that you're familiar with.

Copyright © 1999 - Falcon Networking ISSN 1203-5696
March 16, 1999