Friday, February 6, 2009

Get To Know Linux: Understanding xorg.conf

For most Linux users the xorg.conf file is one of those files that makes many Linux users cringe with fear upon the threat of having to configure. There is a reason for that, it’s complex. But when you have an understanding of the pieces that make up the whole puzzle, configuring X Windows becomes much, much easier.

But now the Linux community has distributions, such as Fedora 10, that do not default to using an xorg.conf file. This is great news for many users. However, it’s bad news when, for some reason, X isn’t working or you have specific needs that the default isn’t meeting. With that in mind we’re going to break down the xorg.conf file so that you will be able to troubleshoot your X Windows configuration when something is wrong.

The Basics

The first thing you need to know is that xorg.conf (located typically in /etc/X11) is broken up into sections. Each section starts with the tag Section and ends with the tag EndSection. Each section can be broken into subsections as well. A subsections starts with the tag SubSection and ends with the tag EndSubSection. So a typical section with subsections contains the tags:
Section Name
Section Information
SubSection Name
SubSection information
EndSubSection
EndSection

Of course you can’t just use random sections. There are specific sections to use. Those sections are:

  • Files - pathnames for files such as fontpath
  • ServerFlags - global Xorg server options
  • Module - which modules to load
  • InputDevice - keyboard and pointer (mouse)
  • Device - video card description/information
  • Monitor - display device description
  • Modes - define video modes outside of Monitor section
  • Screen - binds a video adapter to a monitor
  • ServerLayout - binds one or more screens with one or more input devices
  • DRI - optional direct rendering infrastructure information
  • Vendor - vendor specific information

Each section will have different information/options and is set up:

Option Variable

Let’s take a look at a sample section. We’ll examine a Device section from a laptop. The section looks like:

Section "Device"
Identifier "device1"
VendorName "VIA Technologies, Inc."
BoardName "VIA Chrome9-based cards"
Driver "openchrome"
Option "DPMS"
Option "SWcursor"
Option "VBERestore" "true"
EndSection

The above section configures a Via Chrome video card (often a tricky one to get running) using theopenchrome driver. Here’s how this section breaks down:

  • The identifier (labled “device1″) connects this section to Screen section with the Device “device1″option.
  • The VendorName and BoardName both come from the make and model of the video adapter.
  • The Driver is the driver the video card will use.
  • Option “DPMS” - this enables the Display Power Management System.
  • Option “SWcursor” - this enables the cursor to be drawn by software (as opposed to the HWcursor drawing by hard ware).
  • Option “VBERestore” “true” - allows a laptop screen to restore from suspend or hibernate.

The lengthiest section of your xorg.conf file will most likely be your Screen section. This section will contain all of the subsections that contain the modes (resolutions) for your monitor. This section will start off like this:

Section "Screen"
Identifier "screen1"
Device "device1"
Monitor "monitor1"
DefaultColorDepth 24

Notice how the above section references both a device and a monitor. These will refer to other sections in the xorg.conf file. This section also contains the DefaultColorDepth which will define the default color depth for your machine. In the case above the default is 24. Now, take a look below at the SubSections of this section:

Subsection "Display"
Depth 8
Modes "1440x900" "1280x800"
EndSubsection
Subsection "Display"
Depth 15
Modes "1440x900" "1280x800"
EndSubsection
Subsection "Display"
Depth 16
Modes "1440x900" "1280x800"
EndSubsection
Subsection "Display"
Depth 24
Modes "1440x900" "1280x800"
EndSubsection
EndSection

As you can see there is a SubSection for four different color depths. Included in those subsections is the default 24. So when X reads the DefaultColorDepth option it will automatically attempt to set the modes configured in the Depth 24 subsection. Also notice that each subsection contains two resolutions. X will attempt to set the first resolution (in the case above our first default is 1440×900) and move on to the next if it can not set the first. Most likely X will be able to set the first.

Final Thoughts

This is only meant to be an introduction to the xorg.conf configuration file. As you might guess, xorg.conf, can get fairly complex. Add to the complexity numerous options available for each section and you have a valid case to make sure you RTFM (read the fine man page.) And the man page is an outstanding resource to find information on all of the available options. To read the man page issue the command man xorg.conf from the command line.

By having a solid understanding of the xorg.conf file you won’t have any problems fixing a fubar’d X installation or tweaking your xorg.conf file to get the most from your new video card.

No comments: