Monthly Columns
 

X

Copyright © 1999 Chris Coleman

What is X?
X, or the X Window System, is a graphical user interface for most varieties of UNIX. XFree86 is a free version of X that is used by both BSD and Linux. You can obtain more information about what XFree86 is and how it is developed at XFree86.org.

Where do I get X?
XFree86 ships with FreeBSD, NetBSD, and OpenBSD. The install program for each of the BSD's has an option available for installing the current version of XFree86. Additionally, XFree86 is available in the ports collection. However, if you feel the need to be more than current, you can download the latest and greatest from www.xfree86.org and install it by hand at anytime. The stock XFree86 distribution compiles out of the box on most any BSD system.

How do I know if X is setup and where it installed to?
XFree86 usually installs to /usr/X11R6. On some systems it can install to /usr/X11/. The configuration file for X is /etc/XF86Config. The latest snapshot of XFree86 puts the config file in /etc/X11/XF86Config.

You can find out what version you have installed by typing: X -showconfig.

What do I need to know to setup X?
There are three things that you need to know, or be able to guess accurately. 1) The brand of Video Card that your computer uses. 2) The Horizontal and Vertical Refresh limits of your monitor. 3) What kind of mouse you have and where it plugs in to your computer.

How do I setup X?
There are two different programs that can be used to configure X, xf86config and XF86Setup. xf86config is a text only config program, while XF86Setup launches a graphical configuration utility. In order to use XF86Setup, you must have a VGA capable monitor and video card, as well as have the VGA16 server installed.

Regardless of which program you choose, there are 4 questions that you must answer correctly.
1) The protocol or type of mouse you have attached.
Most new computers ship with PS/2 mice. PS/2 mice have the small round connector. Several of the older mice are serial mice and will be compatible with either the Microsoft 2-button protocol, or the Mouse Systems 3-button protocol. Some exceptions are logitech mice and the new Microsoft IntelliMouses.

2) The device or port that the mouse is attached to.
All mice plug into either the PS/2 port or one of the Serial ports. This is referred to as the "Mouse Device" in xf86config. The device for PS/2 mice is /dev/psm0. If you have a mouse on COM1, it will be /dev/ttyd0. Mice on COM2 are /dev/ttyd1.

You can just specify the appropriate device when asked, such as /dev/psm0 or you can set it to /dev/mouse and then link /dev/mouse to the appropriate mouse port later. If you don't know how to make the link, then 'man ln'.

3) The Horizontal and Vertical Refresh rates of your monitor.
These measurements specify the safe operating range of your monitor. The instruction book that came with your monitor has these specifications listed. If you don't have the instruction book, you can often look these up on the web. If you can't find these anywhere, you can take educated, conservative guesses based on your monitor type.

Common Horizontal refresh rates start at 31.5 kHz and to to 37.9 kHz. Better monitors can 50 kHz or greater. 31.5-35.5 is often a safe setting for SVGA monitors. Common Vertical refresh rates start at 50 Hz and extend to 90 Hz. Better monitors can do 40-150 Hz. 50-90 Hz is often a safe setting for SVGA monitors.

On both settings, the high number is the one to be concerned with. Using a setting that is beyond the limits of your monitor can cause damage to older monitors. Newer monitors often have protection circuits built in to keep this from happening.

4) The type of video card you have.
Video cards are fairly easy to figure out. Usually the video card model or chipset is printed on the side of the card that you have. However, if it is not, most BSD systems can detect the type of card that you have during boot up. You can type 'dmesg | more' and look for the video card description.

After you have successfully run either XF86Setup or xf86config you need to start X. There are two methods of running X. You can start X manually, using the command startx or you can setup a graphical login using xdm. The K Desktop Environment (KDE) comes with its own version of xdm called kdm.

startx is a script that calls the individual files needed to get X running. It is located at /usr/X11R6/bin/startx. You can edit this file if you need to specify any special runtime parameters. When X is started via the startx script, it reads the file .xinitrc from you home directory to start the Window Manager.

Xdm is a graphical login manager for X. It reads the .xsession file from the users home directory to choose the Window Manager to start. Errors for each user are logged to .xsession-errors. If a person cannot login, check .xsession-errors for a list of the problems. I have had to 'chmod u+x .xsession' to get xdm to allow me to login. By default, root logins have been disabled by xdm. You should login as a regular user and 'su root' to get superuser rights.


Window Managers.

The Window Manager is what controls the look and feel of your X desktop. You will need to specify the the Window Manager that you want to use in your .xinitrc and/or .xsession file. If you don't, X will start the system default window manager. There are several Window Managers available. Most are available as pre-compiled packages or as ports. FreeBSD allows you to choose your X desktop during the installation.

How do I stop X?
X can be started and stopped independent of your operating system. By pressing <ctrl> + <alt> + <backspace>, you can signal X to shutdown. If you started X using startx, this will bring you back to your command prompt. If you were using xdm, it will bring up another graphical login screen.

How do I get a terminal screen back while I have X running?
X generally runs on the 4th virtual terminal. You can return to the original terminal by pressing <ctrl> + <alt> + <f1>. You can switch back to X by pressing <alt> + <f4>. This is especially useful if you are running xdm.

This document is only designed to get X installed and configured on your BSD machine. You will also need to do some research on which X Window Manager is right for you. There are several other places you can find out about X:

Online at
http://www.xfree86.org
http://www.cis.ohio-state.edu/hypertext/faq/usenet/x-faqs/top.html
http://formast.lut.ac.uk/ASlab/info/usage/X-doc/XwindowGuide/doc.html

or by reading the man pages for X, xinit, XFree86, Xserver, xdm, and startx.

To recap what you need to do to get X installed:

  • Install X, either from binaries or by compiling the source.
  • Configure the appropriate X server using either xf86config or XF86Setup.
  • Choose and install a Window Manager.
  • Configure your .xinitrc file for use with startx or .xsession for use with xdm.

This should get you started into the world of X on BSD.

Chris Coleman chrisc@vmunix.com