Configuring X

From LQWiki
Jump to: navigation, search

Configuring the X Window System is hopefully done automatically when installing Linux. If it is not (e.g. because you have a lame distro), this article is for you...

Various Tools That Make Things Easier

There are a number programs that automatically configure the X Window System for you. Your first stop should be the tool your distribution provides, so

Some video card makers provide their own tools for you to use, and some distributions also provide their own tools.

Manual editing of the config file

First, figure out what you're favorite (or least hated) cli text editor is. You'll need to edit the file as root, and then restart X after your edit (logging out then logging back in does this).

Customizing your system

    Here are your options:
  1. Use the tool your distribution provides
  2. Edit the /etc/X11/XF86Config-4 file by hand.
  3. Use a third party configuration tool, for example, if you use the ati-drivers, they come with an fglrxconfig tool that inserts special options for the ati cards.

NOTE: If you are using version 4.x chances are your file will be named XF86Config-4. This takes precedence over the old XF86Config file, which was used with XFree86-3.x.

Finer points -- video card settings

If you're using a flat panel monitor, X may automatically enable subpixel font rendering. Subpixel font rendering is undesirable for some because of the very slight color artifacts it creates. To shut it off, you can use fontconfig. On Debian systems, the command is dpkg-reconfigure fontconfig.

With Gnome, there's a desktop settings program that lets you configure how fonts are rendered.

In newer versions of the radeon man page, there should be an option called 'SubPixelOrder', but I don't know the connection between that and fontconfig.

For video cards with 2 outputs (e.g., A DVI port along with a 15-pin VGA port), you may add an option to your "Device" section that looks like:

Option  "MonitorLayout"  "TMDS, NONE"

Again, see man radeon (or the relevant man page for the driver you're using) for more details.

Mouse configuration

The mouse often is the most difficult to get working for new users. You'll want to verify you have a working mouse at /dev/mouse (users with USB will use /dev/input/mice instead). If not, you need to create the link. The easiest way to find out, is just to type:

cat /dev/mouse

Now move your mouse around and you should have random characters fly up your screen. Press "Control-C" to quit. If you don't see strange characters, and you perhaps get back "no such file", then you need to tell your computer you actually have one. See Configuring mice (Serial, PS/2, USB for further help. Come back here when you need to continue.

Within the configuration when asked for the protocol, most people will use PS/2, or IMPS/2 for usb mice. However, if you have an older serial mouse, then you perhaps need to choose "Microsoft" (the most common for two-button mice) or "MouseSystems" if you have a three-button mouse. You will find that if one doesn't work, then the other will. There may even be a switch on the mouse labeled "PC/MS" to select the protocol.

Another option is to see if XFree86 discovers the correct protocol for itself - by putting in "auto". This works for really modern mice (the Explorer types, for example).

A very common problem is getting the scroll wheel to work, if you have one. This is generally very easy to do. There will be a section labeled "InputDevice" that relates to the mouse. Within that section, add the line:

Option "ZAxis Mapping" "4 5"

For older mice that only have two buttons, or do NOT have a clickable wheel (some scroll wheel mice), you may also select to turn on "Emulate3Buttons" by adding the following line:

Option "Emulate3Buttons"</br> Option "Emulate3Timeout" "50"

If you have a mouse with three buttons (or even more, perhaps) then you won't need these two lines. This also applies if your scroll wheel also clicks as well as rolling.

Keyboard

By default, your keys will act as if they were on a US keyboard. To change this, read and follow Configuring keyBoards.

Video cards

If your card has an ATI Radeon chipset, see 'man radeon'. See the DRI website for a list of supported cards/chipsets.

Running the X Window System

Once you have all your hardware details specified correctly, you are ready to test X. For most users, you will have to be the root user to do this step. You are probably at the root prompt already, so type "startx" and wait.

After a few seconds, you ought to see a grey screen with a cross (X) in the middle. It is also possible that KDE may load after this, but we're not counting on that yet. If you get this grey screen, and it sits around, and the cross moves when you move the mouse, then congratulations. Your XFree86 works - but you may need to do a few minor tweaks with regard to resolution or whatever. Hit "Control-Alt-Backspace" together, you will then be put back to the console screen.All you need to do now is fire up KDE or GNOME (or some other window manager).

If you end up with a KDE or GNOME screen, then choose "Logout" from the startup menu. Again, congratulations. You may need to tweak things like available resolutions, and bitdepths, but that is for further discussion in another section.

Setting up Multiple X Sessions on a Single Monitor

In my home environment, my wife prefers to use my principal desktop (now running Fedora Core 4) instead of the kids' Windows machine. One possible solution would be to log out of my X session and let her log in under her own userid. But this is time-consuming and disruptive. Another approach would be to simply let her use my account. But this is an unnecessary compromise.

The most elegant solution is to run two X servers concurrently and let us switch back and forth between them as required. So, Control-Alt-F7 is my X server and Control-Alt-F8 is my wife's session.

Testing the Second Session

The first step is to test the second session manually. Simply log to a console window (Control-Alt-F1 for example) and type the following:

  • startx -- :1 vt8

This will start an X server on virtual terminal 8 and the DISPLAY environment variable will be :1.0 instead of :0.0.

The :1 is the display name and vt8 is the virtual terminal number. Since vt7 is the default terminal for X, and I running consoles on vt1-vt6, I chose vt8 for the second X session. Be sure that it isn't already being used for a console. Console VTs are started by /etc/inittab.

Making the Change Automatic

Typically, X is started when init changes to runlevel 5. If you look at /etc/inittab, you will see a record that looks like:

  • x:5:once:/etc/X11/prefdm -nodaemon

This in turn will run the appropriate display manager. By default, this is gdm or kdm and the choice is dependent on the value of the DESKTOP variable defined in /etc/sysconfig/desktop. I don't believe that the gnome desktop manager supports multiple displays. This may have changed since my original investigation some time ago. In any event, I found that even though my desktop is "GNOME", I needed to use the xdm display manager. You can override this default by having the following two records in /etc/sysconfig/desktop:


  DESKTOP="GNOME"
  DISPLAYMANAGER="XDM"

Now, when you switch to runlevel 5 (which is the default at boot time), you will be using the XDM window manager instead of kdm or gdm. The next step is configure xdm to start the second session. This is done by simply adding another record to the /etc/X11/xdm/Xservers file:


  :0 local /usr/X11R6/bin/X :0 vt7
  :1 local /usr/X11R6/bin/X :1 vt8

Verifying Your Changes

You don't need to reboot for this to take effect. Simply log out of your X session, switch to a lower run-level, and then switch back to run-level 5:


  • init 3
  • init 5

This should kill your current display manager on vt7 and then restart the new display manager twice: once on vt7 and again on vt8.

Caveats

  • This works in my stock xorg environment. It may not work in yours.
  • Upon casual inspection, it looks like kdm is based on xdm and uses the same Xservers configuration file. If your DISPLAYMANAGER is KDE, this above changes will likely work as well. No guarantees.
  • Each X server can consume a fair bit of memory. Having two users share the same workstation might be a bit painful if you only have 256MB of RAM. I have 1GB and there is no performance issue.

What? No graphics?

If you GET something that looks more like text, and stays at your console, then you need to work out (from what XFree86 said) what section you need to alter. XFree86 also leaves a log file in /var/log/XFree86.0.log for you to look at, but this is a pretty long file to look at for people new to the process.

(Needs to be filled in further) Common reasons for this include:

X couldn't figure out what your card was.
This is common when you have an older version of X and a really new video card. Examples of this can include having an Intel 845 graphics chipset, and not having a Intel 845 driver within your version of X. This is a very specific example of a card that will not work (properly) with an Intel 830 driver). Mostly, upgrading either X itself, or the whole distribution itself will generally cure this. If you already HAVE the latest, then you have some work to do.
It found your card, but "no suitable screens were found"
This can happen if you didn't correctly specify what resolutions you wanted to make available. This can also include selecting correct bitdepths (8, 16, 24 or 32-bit resolutions). When you have a modern flat-panel display, it's even more important you get the available resolutions correct.

TODO: We will probably need to break up sections of the X configuration process (now done) and organize it nicely. This is just a slightly less rough overview. Categories about video cards and screens need to be filled out, as well as the troubleshooting section.

screensaver

Typing xscreensaver at the prompt will launch a diaolog to edit your preferences. You can also go in manually; grep for xscreensaver, it'll be something like /usr/X11R6/lib/X11/app-defaults/XScreenSaver

See also