The X Server Configuration HOWTO
1. What is the X Window Server?
Graphical vs Command-Line
The average user may be frightened at the thought of having to type in commands.
Why wouldn't he be able to point and click his way through the freedom provided
by Gentoo (and Linux in general)? Well, *big smile*, of course you are able to
do this :-) Linux offers a wide variety of flashy user interfaces and
environments which you can install on top of your existing installation.
This is one of the biggest surprises new users come across: a graphical user
interface is nothing more than an application which runs on your system. It is
not part of the Linux kernel or any other internals of the system. It is
a powerful tool that fully enables the graphical abilities of your workstation.
As standards are important, a standard for drawing and moving windows on a
screen, interacting with the user through mouse and keyboard and other basic yet
important aspects has been created and named the X Window System,
commonly abbreviated as X11 or just X. It is used on Unix, Linux
and Unix-like operating systems throughout the world.
The application that provides Linux users with the ability to run graphical
user interfaces and that uses the X11 standard is Xorg-X11, a fork of
the XFree86 project. XFree86 has decided to use a license that might not be
compatible with the GPL license; the use of Xorg is therefore recommended. Note
though that the differences between Xorg and XFree86 are currently very slim; if
you know one, you know the other. XFree86 versions prior to 4.4 are available
through Portage as well.
The X.org Project
The X.org project created and
maintains a freely redistributable open-source implementation of the X11 system.
It is an open source X11-based desktop infrastructure.
Xorg provides an interface between your hardware and the graphical software
you want to run. Besides that, Xorg is also fully network-aware, meaning you
are able to run an application on one system while viewing it on a different
one.
2. Installing Xorg
Using emerge
Enough chitchat, let's get to business shall we? To install Xorg, you just
need to run emerge xorg-x11. Installing Xorg does take a while
though, so you might want to grab a snack while you are waiting.
Code Listing 2.1: Installing Xorg |
# emerge xorg-x11
|
When the installation is finished, you might need to reinitialise some
environment variables before you continue. Just run env-update followed
by source /etc/profile and you're all set. This doesn't harm your system
in any way.
Code Listing 2.2: Reinitialising the environment variables |
# env-update
# source /etc/profile
|
3. Configuring Xorg
The xorg.conf File
The configuration file of Xorg is called xorg.conf and it
resides in /etc/X11. The Xorg-X11 package provides an example
configuration as /etc/X11/xorg.conf.example which you can use to
create your own configuration. It is heavily commented, but if you are in need
of more documentation regarding the syntax, don't hesitate to read the man page:
Code Listing 3.1: Reading the xorg.conf man page |
# man 5 xorg.conf
|
Happy reading for those of you willing to. We surely don't so we'll continue
with checking out how we can create the file automatically.
Default: Automatic Generation of xorg.conf
Xorg itself is able to guess most parameters for you. In most cases, you
will only have to change some lines to get the resolution you want up and
running. If you are interested in more in-depth tweaking, be sure to check the
resources at the end of this chapter. But first, let us generate a (hopefully
working) Xorg configuration file.
Code Listing 3.2: Generating an xorg.conf file |
# Xorg -configure
|
Be sure to read the last lines printed on your screen when Xorg has finished
probing your hardware. If it tells you it failed at some point, you're forced to
manually write an xorg.conf file. Assuming that it didn't fail, it
will have told you that it has written /root/xorg.conf.new ready
for you to test. So let's test :)
Code Listing 3.3: Testing the xorg.conf.new file |
# X -config /root/xorg.conf.new
|
If all goes well, you should see an ugly, loathsome, repulsive, deformed
window manager called twm, probably the smallest window manager
available. Try moving your mouse and see if your keyboard and such is working.
In the next section we will optimize our xorg.conf so it fits your
hardware. Now go into one of the terminals you see on your screen and type in
exit (or press Ctrl-D) until Xorg shuts down. If you are unable to
use your mouse to focus the terminals, you can also press Ctrl-Alt-Backspace to
kill the X server.
Alternative: Semi-Automatic Generation of xorg.conf
Xorg provides a tool called xorgconfig which will ask you for various
information regarding your system (graphical adapter, keyboard, ...). Based on
your input it will create a xorg.conf file.
Code Listing 3.4: Semi-Automatic Generation of xorg.conf |
# xorgconfig
|
4. Tweaking xorg.conf
Copying over xorg.conf
Let us first copy over the xorg.conf.new to
/etc/X11/xorg.conf so we won't have to continuously run Xorg
-config -- typing startx is far more easy :)
Code Listing 4.1: Copying over xorg.conf |
# cp /root/xorg.conf.new /etc/X11/xorg.conf
|
Now run startx to start up your X server. It will use the freshly copied
file as its configuration file. To finish the X session, type in exit or
Ctrl-D in the upcoming xterms. You can also kill the X session using the
Ctrl-Alt-Backspace combination. This will however make X exit disgracefully -
something that you might not always want. It doesn't hurt though :)
Code Listing 4.2: Starting X |
# startx
|
Setting your Resolution
If you feel that the screen resolution is wrong, you will need to check two
sections in your configuration. First of all, you have the Screen section
which lists the resolutions - if any - that your X server will run at. By
default, this section might not list any resolutions at all. If this is the
case, Xorg will estimate the resolutions based on the information in the
second section, Monitor.
What happens is that Xorg checks the settings of HorizSync and
VertRefresh in the Monitor section to compute valid resolutions.
For now, leave these settings as-is. Only when the changes to the Screen
section (which we will describe in a minute) don't work, then you will need to
look up the specs for your monitor and fill in the correct values. You can also
use a tool that searches for your monitor's specs, such as
sys-apps/ddcxinfo-knoppix.
Warning:
Do not "just" change the values of these two monitor-related variables
without consulting the technical specifications of your monitor. Setting
incorrect values lead to out-of-sync errors at best and smoked up screens at
worst.
|
Now let us change the resolutions. In the next example from
/etc/X11/xorg.conf we add the Modes lines and the
DefaultDepth so that our X server starts with 24 bits at 1024x768 by
default. Don't mind the given strings - they are examples and will most likely
differ from the settings on your system.
Code Listing 4.3: Changing the Screen section in /etc/X11/xorg.conf |
Section "Screen"
Identifier "Default Screen"
Device "S3 Inc. ProSavage KN133 [Twister K]"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x768"
EndSubSection
EndSection
|
Run X (startx) to discover it uses the resolution you want :)
Configuring your Keyboard
To setup X to use an international keyboard, search for the InputDevice
section that configures the keyboard and add the XkbLayout option to
point to the keyboard layout you want. As an example, we show you how to apply
for the Belgian layout. Just substitute the country-keycode with yours:
Code Listing 4.4: Changing the keyboard layout |
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "keyboard"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "be"
EndSection
|
Configuring your Mouse
If your mouse isn't working, you will first need to find out if it is detected
by the kernel at all. PS/2 mice are (device-wise) seen as
/dev/psaux. Other mice (like USBs) are seen as
/dev/input (or /dev/input/mice). In either case you
can check if the devices do represent your mouse by checking the output of those
files when you move your mouse. To end the session press Ctrl-C.
Code Listing 4.5: Checking the device files |
# cat /dev/input
|
If your mouse isn't detected, verify if all the necessary modules are loaded.
If your mouse is detected, fill in the device in the appropriate
InputDevice section. In the next example you'll see we also set two other
options: Protocol (which lists the mouse protocol to be used - most users
will use PS/2 or IMPS/2) and ZAxisMapping (which allows for the
mousewheel (if applicable) to be used).
Code Listing 4.6: Changing the mouse settings in Xorg |
Section "InputDevice"
Identifier "TouchPad Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/psaux"
Option "Protocol" "IMPS/2"
Option "ZAxisMapping" "4 5"
EndSection
|
Run startx and be happy about the result :) Congratulations, you now
(hopefully) have a working Xorg on your system. The next step is to remove this
ugly lightweight window manager and use a high-feature one (or even a desktop
environment) such as KDE or GNOME, but that's not part of this guide :)
5. Resources
Creating and Tweaking xorg.conf
First of all, man 5 xorg.conf provides a quick yet complete reference
about the syntaxis used by the configuration file. Be sure to have it open on a
terminal near you when you edit your configuration file!
A second point of resources on your system is the
/usr/X11R6/lib/X11/doc directory with various README's
for individual graphical chipsets.
There are also many online resources on editing xorg.conf. We only
list few of them here, be sure to Google
for more :) As xorg.conf and XF86Config (the
configuration file for the XFree86 project) use the
same syntaxis for most configuration options and more information about
XF86Config is available, we'll list those resources as well.
The contents of this document are licensed under the Creative Commons - Attribution / Share Alike license.
|