Task 2.8: Configure X Options
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Several implementations of the X Window System (X for short) are available, but the most common ones today use identical configuration file formats. The older XFree86 3.3.6 and earlier configuration file differs in some important details, but such old versions of XFree86 are becoming quite rare. The rarer commercial implementations of X use their own configuration file formats, which I don't describe.
As part of ongoing system upgrades at your site, you've replaced the video card, monitor, and mouse on one computer. The new video card is a generic board that uses an nVidia GeForce video chipset; the monitor is a 17-inch liquid crystal display (LCD) device capable of 1280×1024 resolution; and the mouse is a USB model with a scroll wheel. Changing this hardware necessitates making several alterations to the X configuration file.
Scope of Task
This task describes changing the three specified pieces of hardware; however, you're unlikely to rush out and buy new hardware just to complete this task. In this case, you should read along and review your existing configuration file without changing it. If you happen to have spare hardware, you might try temporarily installing and configuring it, though.
This task will take about an hour or two to complete, including installing the new hardware. If you don't actually replace any hardware, it should take only about half an hour to review the configuration file options. In real life, replacing hardware often results in unexpected complications, which can increase the time to perform tasks such as this.
If you have an extra video card and want to try actually replacing the hardware, you should shut down the computer and perform the physical replacement. Be sure to follow the usual safety precautions when working inside the computer—unplug the computer from the wall outlet and ground yourself before touching anything inside the computer. Replacing the mouse doesn't require opening the computer, but some older (non-USB) mice should only be plugged in or unplugged when the computer is powered down.
Once you've replaced the hardware, or if you don't have spares and intend to just read along, boot the computer. Some distributions will detect hardware changes and reconfigure themselves automatically, but others won't. Because this task is intended to teach you how to reconfigure the system yourself, you should tell your computer not to make automatic changes if it offers to do so.
If you've changed your video card, chances are you won't see a GUI login screen. Changing the monitor alone might or might not result in a blank screen, and changing the mouse alone might result in a system for which the mouse doesn't work. In any of these cases, press Ctrl+Alt+F1 to get a text-mode login prompt and log in. If you need to make real changes, type suto acquire superuser privileges; if not, continue using your regular account.
Swapping hardware runs some risk of damaging it. Be careful not to touch delicate components unnecessarily, and ground yourself by touching a radiator or plumbing before handling the video card or touching any other internal components. (You can also buy anti-static wrist straps or work pads that connect to your building's electrical grounding system.) There's also a chance of your injuring yourself, particularly if you work on a computer that's plugged into a wall outlet. Ordinarily, the 120-volt AC from the wall outlet is reduced to much lower-voltage DC current inside the case, but a fault could expose you to more dangerous current.
As usual, if you make actual changes to your configuration as root, you run the risk of damaging your system software. Backing up your X configuration file will enable you to recover if you make an error when editing that file. A backup will also enable you to easily restore your original configuration if you make test changes and then swap your hardware back to its original state.
The X configuration file, like most Linux configuration files, is a text-mode file with options you can alter in a text editor. Before making real changes, you should familiarize yourself with some fundamental X principles and with the basic structure of the configuration file. After that, you can go on to change your mouse, monitor, and video card configurations for the hardware you've installed (or just examine these options if you've not actually changed your hardware).
X is Linux's GUI environment. Like most other Linux tools, X is a separate software component that can be replaced with workalike software and that's configured independently of many other subsystems. Traditionally, XFree86 (http://www.xfree86.org) has been the most popular X server for Linux; however, most Linux distributions now use X.org-X11 (http://www.x.org) instead.
Technically, X is a server, much like a file server or mail server. Where a file server enables programs to read and write files, though, X enables programs to read from the keyboard and write to the screen. X's server nature gives it certain unusual networking capabilities, some of which are described shortly, in Task 2.9, "Manage X Logins."
To configure X, you edit the X configuration file, which goes by various names. For XFree86, the configuration file is called XF86Config or XF86Config-4 and is located in /etc/X11 or /etc. For X.org-X11, the configuration file is xorg.conf, which is normally stored in /etc/X11. The configuration files for X.org-X11 and XFree86 4.x are identical in format. Before proceeding further, you should change to the /etc/X11 directory (or possibly just /etc), back up the configuration file, and then load the original into your favorite text-mode editor. (Task 1.5 in Phase 1 describes using Vi for this purpose.)
Familiarizing Yourself with the Configuration File
The X server configuration file is broken down into multi-line sections, one section for each major feature (mouse, keyboard, video card, and so on). Each of these sections begins with a line consisting of the keyword Sectionand the section name in quotes. Each section ends with the keyword EndSection:
Identifier "Keyboard0" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "us" Option "AutoRepeat" "500 200" EndSection
This section tells X about the keyboard—its model, layout, and so on. If you examine your X configuration file, you'll find several sections:
Files This section tells X where to find files that it needs. In many cases, this section consists of nothing but FontPathentries, which tell X where to find fonts. X font configuration is actually fairly complex, but the font settings in the X configuration file have been falling in importance in recent years. Most X programs now use Xft fonts, which are configured via files in the /etc/ fonts/directory.
You can set miscellaneous server options in this section. Chances are you won't need to adjust it unless you need to alter advanced or obscure options, such as the X server's built-in power-saving options. (Most desktop environments provide other ways to set such options.)
Modern X servers are modular, in the sense that they consist of a main program file (such as /usr/X11R6/bin/Xorg) and separate module files that contain drivers for specific video hardware, font-handling routines, and so on. The Modulesection tells X which of these modules to load. Chances are you won't need to adjust this section.
Most X configuration files contain at least two InputDevicesections: one for the mouse and one for the keyboard. You can adjust these sections to better match your hardware, and the upcoming section "Changing the Mouse Configuration" describes how to do this if you change your mouse.
The Monitorsection tells X about your monitor's capabilities. This section is very important for proper X functioning, and the upcoming section "Changing the Monitor Configuration" describes how to adjust it.
This section provides information on your video card, including the driver it's to use and hardware-specific options. The upcoming section "Changing the Video Configuration" describes how to adjust it if you change your video card.
In order to work correctly, X needs to know how to combine the monitor and video card information set in the Monitorand Devicesections. This is the job of the Screensection. You also set options such as the display resolution in this section.
XFree86 4.x and X.org-X11 use the ServerLayout section to combine all the other sections into a coherent whole. This enables you to define multiple mice, use several displays, and so on. Earlier versions of XFree86 lacked this section, the result being less flexibility; these older versions of X could only use a single display and mouse, for instance.
For more information on all of these sections and the options you can set in them, consult the X configuration file man page—type man XF86Config if you use XFree86 or man xorg.conf if you use X.org-X11.
Changing the Mouse Configuration
Because you've replaced your mouse, you should first locate the InputDevice section that describes the old mouse. Chances are it begins with an Identifier line with a name such as
Mouse or Mouse1 and a Driver line with a name of mouse. To use a new USB wheel mouse, you must ensure that three Option lines are set:
The Protocol option tells X how to communicate with the mouse. Several protocols have been used over the years, but modern PS/2 and USB mice all use the PS/2protocol or variants of it. Wheel mice almost invariably use the IMPS/2protocol, so you should set this line to that value.
The Deviceoption tells X what Linux device file interfaces to the mouse. This could be /dev/mouse, /dev/input/mouse0, or something similar. If you're replacing one USB mouse with another, you shouldn't need to adjust this option. The Linux udevfilesystem, used on most modern distributions, should automatically create an appropriate device file, but the name might differ from one distribution to another.
This strangely named option tells X about the wheel on the mouse. It should be set to a value of 4 5. Behind the scenes, wheel movements are sent from the mouse to the computer as button presses, and this option tells X to treat the presses of these buttons (numbers 4 and 5) as wheel movements. Note that not all programs recognize wheel movements, but most modern X programs do.
In sum, a proper configuration for a modern USB wheel mouse looks something like this:
Section "InputDevice" Identifier "Mouse1" Driver "mouse" Option "Protocol" "IMPS/2" Option "Device" "/dev/input/mouse0" Option "ZAxisMapping" "4 5" EndSection
As noted earlier, though, the Devicefile might differ from /dev/input/mouse0. If you're installing something other than a modern USB mouse, you may need to make more radical changes, such as changing the Protocol and omitting or changing the ZAxisMapping line.
Changing the Monitor Configuration
The Monitor section tells X about your monitor's capabilities. Two options are particularly critical for this section: HorizSyncand VertRefresh. These lines tell X about your monitor's horizontal and vertical refresh rates, respectively. Traditional cathode ray tube (CRT) monitors use an electron beam to "paint" a picture on the screen, but the electron beam has a limited scanning speed. The horizontal and vertical refresh rates are the limits on the display's speed for both horizontal scanning (to display a single line of pixels) and vertical scanning (to display an entire screen). The horizontal and vertical refresh rates are measured in megahertz (MHz) and hertz (Hz), respectively. Although LCD monitors don't use electron beams, many of them do have analog interfaces so that they can be used with traditional video cards; thus, these values are important for LCD monitors as well as for CRT monitors.
Unfortunately, you can't tell just by looking at a monitor what its horizontal and vertical refresh limits are; you'll have to crack open the monitor's manual. This information should appear somewhere, probably on a technical specifications page. If you don't have your monitor's manual, try the manufacturer's Web site. Once you have the information, copy it to the Monitor section:
HorizSync 30.0-80.0 VertRefresh 55-75
You can also examine, and perhaps change, other options in the Monitor section. The Identifier line is used in the Screen section for tying things together. You don't need to change this unless you've copied the whole Monitor section so as to leave the original intact. If you've done this, be sure to change the reference in the Screen section when you get to it. The VendorName and ModelName lines provide model information for human consumption.
One of the most confusing types of lines is the ModeLine. These lines provide timing information to enable X to display screens of different resolutions. In the days of XFree86 3.3.6 and earlier, ModeLineentries were commonplace. With XFree86 4.x and X.org-X11, the X server is able to communicate with the monitor to obtain equivalent information from the monitor itself—at least, when using modern video hardware. Thus, you probably don't need to add or adjust any ModeLine entries when you replace a monitor.
Changing the Video Configuration
The main function of the Device section is to identify your video card's driver. This is done via the Driver line. For most boards with nVidia chipsets, such as the one described in this task's Scenario section, you would specify a driver of nv. The resulting section would look something like this:
Section "Device" Identifier "mx4000" BoardName "EVGA e-GeForce MX4000" Driver "nv" Option "DPMS" EndSection
Video card manufacturers are increasingly providing their own X drivers, and in fact nVidia is particularly good in that respect. If you use the video card manufacturer's driver, you would specify it instead of the driver that comes with your X server, such as nvidia rather than nv. Read the documentation that comes with the manufacturer's drivers for detailed installation instructions.
The Identifieroption is used to tie things together later in the file; change it only if you copied the entire section to create a new one, and then be sure to change it in the Screen section, too. The BoardName option is for human use, so change it or not, as you see fit. Additional Option lines set miscellaneous features, some of them driver- or board-specific. Unless you know to do otherwise, it's probably best to leave them as they are.
If you don't know what driver to use, consult your X server's documentation. You may be able to find some clues by examining the X driver module files. These appear in a directory such as /usr/lib/xorg/modules/drivers/ or /usr/lib64/modules/drivers/, depending on your distribution and X server. Drivers have names that end in _drv.o; the part before that string is the driver name that you would enter on the Driverline. You may see a name that seems promising for your card, in which case you can consult the manpage for that driver—for instance, type man tridentif you think the trident_drv.o file might be appropriate for your hardware.
X drivers, like most Linux drivers, are written for chipsets, not cards. The man- ufacturer of your video card might not be the same as the manufacturer of your video chipset, so you might need to dig a bit to figure out who made the video chipset.
Putting It All Together
The Screensection ties together the Monitorand Devicesections, so be sure you point to the correct sections:
Device "mx4000" Monitor "monitor1"
If you didn't change the Identifier lines in the earlier sections, you shouldn't need to make any changes here.
In addition to pointing to the correct Monitorand Devicesections, the Screensection tells X what resolution and color depth to use. The DefaultDepth option sets the default color depth, in bits per pixel:
As a general rule, 24 is a good value here for modern hardware; however, older hardware might work better with 16-, 15-, or even 8-bit color, at the cost of a reduced number of colors in the display. Occasionally 32-bit color depth works better than 24-bit color. The greater the color depth, the slower the display will be, but this slowdown is generally not a serious problem with even low-end modern video hardware.
Setting the DefaultDepthline tells X which Displaysubsection to use. These subsections specify what video resolutions to use:
Subsection "Display" Depth 24 Modes "1280x1024" "1024x768" "800x600" "640x480" Virtual 1280 1024 EndSubsection
In this example, X is instructed to try 1280×1024, 1024×768, 800×600, and 640×480 displays, in that order. If X's mode lines (specified by the ModeLineentries in the Monitorsection or as obtained from the monitor itself), HorizSync, and VertRefreshentries don't permit use of a particular resolution, X ignores it and tries the next one in the list. The Virtualline tells X to create a virtual display as large as the specified size. For instance, if X can only manage a 1024×768 display, that display will act like a panning window onto a larger 1280×1024 display. The display will pan when you move your mouse close to the edge of the physical display.
In addition to the Screen section, you should examine the ServerLayout section. This section ties together one or more Screensections and one or more InputDevicesections. Depending upon how you made your changes, you might or might not need to adjust this section.
Testing Your Changes
Once you've saved the changes to your X configuration file, you can test them. One way to do this is to type startx at a text-mode command prompt. (You can do this as an ordinary user.) X should start up and you should be able to use your new mouse, video card, and monitor. If X fails to start, examine the error messages it displays. If you're lucky, you'll immediately spot a typo or other simple error you can fix. If you're less lucky, you might need to spend time fiddling with the Modesline in your Screen section's Display subsection, reading documentation on your video driver, or otherwise troubleshooting the problem.
Starting X via the startxcommand may start up a different window manager or desktop environment than you see when you log in via a GUI login prompt. If this happens, don't worry; just read on….
Once you're sure your new configuration is working, you can begin using it normally. If your system normally presents a GUI login prompt, rebooting will bring it up, or you can read
Criteria for Completion
This task involves changing hardware and modifying your X configuration. To complete the entire task, you should have swapped out your computer's video card, monitor, and mouse and gotten a working system using the new hardware. If you don't have access to replacement hardware, you should at least have read the description of what to do and become familiar with the X configuration file generally.
Use the following table of contents to navigate to chapter excerpts, or click here to view Chapter 2 in its entirety.
|ABOUT THE BOOK:|
|Hit the ground running with the street-smart training you'll find in Linux Administrator Street Smarts: A Real World Guide to Linux Certification Skills. Using a "year in the life" approach, it gives you an inside look at Linux administration, with key information organized around the actual day-to-day tasks, scenarios, and challenges you'll face in the field. This valuable training tool is loaded with hands-on, step-by-step exercises covering all phases of Linux administration. Purchase the book from Wiley Publishing|
|ABOUT THE AUTHOR:|
|Roderick W. Smith left a career in academia to pursue his passion for computers. He is particularly interested in Linux and Open Source Software, and has written several books.|