Xorg is the public, open-source implementation of the X window system version 11. Since Xorg is the most popular choice among Linux users, its ubiquity has led to making it an ever-present requisite for GUI applications, resulting in massive adoption from most distributions. See the Xorg Wikipedia article or visit the Xorg website for more details.

Installation

Udev will detect your hardware and evdev will act as the hotplugging input driver for almost all devices. Udev is provided by systemd and xf86-input-evdev is required by xorg-server, so there is no need to explicitly install those packages.

Running

If you want to start X without a display manager, install the package xorg-xinit. Optionally, the packages xorg-twm, xorg-xclock and xterm allows for a default environment, as described below.

The startx and xinit commands will start the X server and clients (the startx script is merely a front end to the xinit command). To determine the client to run, startx/xinit will first look to parse a ~/.xinitrc file in the user's home directory. In the absence of ~/.xinitrc, it defaults to the global file /etc/X11/xinit/xinitrc, which defaults to starting a basic environment with the Twm window manager, Xclock and Xterm.

Note: X must always be run on the same tty where the login occurred, to preserve the logind session. This is handled by the default /etc/X11/xinit/xserverrc.

Warning: If you choose to use xinit instead of startx, you are responsible for passing -nolisten tcp and ensuring the session does not break by starting X on a different tty.

If a problem occurs, then view the log at /var/log/Xorg.0.log. Be on the lookout for any lines beginning with (EE), which represent errors, and also (WW), which are warnings that could indicate other issues.

If there is an empty.xinitrc file in your $HOME, either delete or edit it in order for X to start properly. If you do not do this X will show a blank screen with what appears to be no errors in your Xorg.0.log. Simply deleting it will get it running with a default X environment.

Configuration

Note: Arch supplies default configuration files in /etc/X11/xorg.conf.d, and no extra configuration is necessary for most setups.

Xorg uses a configuration file called xorg.conf and files ending in the suffix .conf for its initial setup: the complete list of the folders where these files are searched can be found at [1] or by running man xorg.conf, together with a detailed explanation of all the available options.

Using .conf files

The /etc/X11/xorg.conf.d/ directory stores user-specific configuration. You are free to add configuration files there, but they must have a .conf suffix: the files are read in ASCII order, and by convention their names start with XX- (two digits and a hyphen, so that for example 10 is read before 20). These files are parsed by the X server upon startup and are treated like part of the traditional xorg.conf configuration file. The X server essentially treats the collection of configuration files as one big file with entries from xorg.conf at the end.

Using xorg.conf

Xorg can also be configured via /etc/X11/xorg.conf or /etc/xorg.conf. You can also generate a skeleton for xorg.conf with:

# Xorg :0 -configure

This should create a xorg.conf.new file in /root/ that you can copy over to /etc/X11/xorg.conf.

Alternatively, your proprietary video card drivers may come with a tool to automatically configure Xorg: see the article of your video driver, NVIDIA or AMD Catalyst, for more details.

Note: Configuration file keywords are case insensitive, and "_" characters are ignored. Most strings (including Option names) are also case insensitive, and insensitive to white space and "_" characters.

Input devices

Installing input drivers is not needed for most hardware. Nevertheless, if evdev does not support your device, install the needed driver from the xorg-drivers group (try pacman -Sg xorg-drivers for a listing).

You should have 10-evdev.conf in the /etc/X11/xorg.conf.d directory, which manages the keyboard, the mouse, the touchpad and the touchscreen.

Touchpad Synaptics

After installation, you can find 10-synaptics.conf in the /etc/X11/xorg.conf.d directory. It is safe to comment out/delete the InputClass line regarding the touchpad in 10-evdev.conf.

Disabling input hot-plugging

Since version 1.8 Xorg-server uses udev for device detection. The following will disable the use of udev.

Section "ServerFlags"
Option "AutoAddDevices" "False"
EndSection

Warning: This will disable Xorg hot-plugging for all input devices and revert to the same behavior as xorg-server 1.4. It is much more convenient to let udev configure your devices. Therefore, disabling hot-plugging is not recommended!

Keyboard settings

Xorg may fail to detect your keyboard correctly. This might give problems with your keyboard layout or keyboard model not being set correctly.

To see a full list of keyboard models, layouts, variants and options, open /usr/share/X11/xkb/rules/xorg.lst.

To set the keymap for the current Xorg session:

$ setxkbmap dvorak

Key repeat delay and rate

Use xset r rate DELAY RATE to change them, then use xinitrc to make it permanent. Values 170 and 30 are a good start point.

Setting keyboard layout with hot-plugging

Note: If you use GNOME, these settings will be ignored. You will have to set the keyboard layout from the GNOME Keyboard applet. Follow the Keyboard Layout link and add the layout you require and remove any you do not. For XkbOptions, see GNOME#Modify_Keyboard_with_XkbOptions.

To change your keyboard layout, create a number-*.conf file (e.g. 10-keyboard.conf) with the following content:

Setting keyboard layout without hot-plugging (deprecated)

To change the keyboard layout, use the XkbLayout option in the keyboard InputDevice section. For example, if you have a keyboard with the English (Great Britain) layout, your keyboard InputDevice section might look similar to this:

To change the keyboard model, use the XkbModel option in the keyboard InputDevice section. For example, if you have a Microsoft Wireless Multimedia Keyboard:

Option "XkbModel" "microsoftmult"

Switching between keyboard layouts

To be able to easily switch keyboard layouts, modify the Options used in either of the above two methods. For example, to switch between a US and a Swedish layout using the Template:Keypress key, create a file /etc/X11/xorg.conf.d/01-keyboard-layout.conf with the following content:

This is mainly useful if you run a Desktop Environment which does not take care of keyboard layouts for you.

Tip: If you want to get a list of possible values for the layout and options, you can find them in /usr/share/X11/xkb/rules/xorg.lst. They are under sections ! layout and ! option respectively. These values work for both the configuration file solution, and the command line alternative.

InputClasses

InputClasses are a new type of configuration section that does not apply to a single device but rather to a class of devices, including hotplugged devices. An InputClass section's scope is limited by the matches specified – to apply to an input device, all matches must apply to a device. An example InputClass section is provided below:

If this snippet is present in the xorg.conf or xorg.conf.d, any touchpad present in the system is assigned the synaptics driver. Note that due to precedence order (alphanumeric sorting of xorg.conf.d snippets) the Driver setting overwrites previously set driver options – the more generic the class, the earlier it should be listed. The default snippet shipped with the xorg-x11-drv-Xorg package is 00-evdev.conf and applies the evdev driver to all input devices.

The match options specify which devices a section may apply to. To match a device, all match lines must apply. The following match lines are supported (with examples):

MatchIsPointer, MatchIsKeyboard, MatchIsTouchpad, MatchIsTouchscreen, MatchIsJoystick – boolean options to apply to a group of devices.

MatchProduct "foo|bar": match any device with a product name containing either "foo" or "bar"

MatchVendor "foo|bar|baz": match any device with a vendor string containing either "foo", "bar", or "baz"

MatchDevicePath "/dev/input/event*": match any device with a device path matching the given patch (see fnmatch(3) for the allowed pattern)

MatchTag "foo|bar": match any device with a tag of either "foo" or "bar". Tags may be assigned by the config backend – udev in our case – to label devices that need quirks or special configuration.

Example configurations

The following subsections describe example configurations for commonly used configuration options. Note that if you use a desktop environment such as GNOME or KDE, options you set in the xorg.conf may get overwritten with user-specific options upon login.

Example: Wheel emulation (for a Trackpoint)

If you own a computer with a Trackpoint (a Thinkpad, for example) you can add the following to the xorg.conf to use the middle button to emulate a mouse wheel:

Here you see the Option "Emulate3Buttons" "True" and Option "Emulate3Timeout" "25" options that specify that 3 buttons should be emulated and the delay to recognize both buttons down as a middle click is 25ms.

Graphics

Driver installation

The default graphics driver is vesa (xf86-video-vesa), which handles a large number of chipsets but does not include any 2D or 3D acceleration. To enable graphics acceleration, you will need to install and use the driver specific to your graphics card.

First, identify your card:

$ lspci | grep VGA

Then, install an appropriate driver. You can search for these packages with the following command:

Script to toggle internal/external display for laptops

Run the following script after connecting to external displays with your computer to change the display used by Xorg. It checks if a display is connected to the port specified in EXT before changing displays.

To find out the display names to be specified in EXT run:

# xrandr -q

The internal display should be connected when running the script, which is always true for a laptop. To use this script the package xorg-xrandr needs to be installed.

Display Size and DPI

If this is not used, the DisplaySize setting in the X config file is used to derive the DPI, given the screen resolution.

If no DisplaySize is given, the monitor size values from DDC are used to derive the DPI, given the screen resolution.

If DDC does not specify a size, 75 DPI is used by default.

In order to get correct dots per inch (DPI) set, the display size must be recognized or set. Having the correct DPI is especially necessary where fine detail is required (like font rendering). Previously, manufacturers tried to create a standard for 96 DPI (a 10.3" diagonal monitor would be 800x600, a 13.2" monitor 1024x768). These days, screen DPIs vary and may not be equal horizontally and vertically. For example, a 19" widescreen LCD at 1440x900 may have a DPI of 89x87. To be able to set the DPI, the Xorg server attempts to auto-detect your monitor's physical screen size through the graphic card with DDC. When the Xorg server knows the physical screen size, it will be able to set the correct DPI depending on resolution size.Xorg always sets dpi to 96. See this, this and finally this.

To see if your display size and DPI are detected/calculated correctly:

$ xdpyinfo | grep -B2 resolution

Check that the dimensions match your display size. If the Xorg server is not able to correctly calculate the screen size, it will default to 75x75 DPI and you will have to calculate it yourself.

If you have specifications on the physical size of the screen, they can be entered in the Xorg configuration file so that the proper DPI is calculated:

If you do not have specifications for physical screen width and height (most specifications these days only list by diagonal size), you can use the monitor's native resolution (or aspect ratio) and diagonal length to calculate the horizontal and vertical physical dimensions. Using the Pythagorean theorem on a 13.3" diagonal length screen with a 1280x800 native resolution (or 16:10 aspect ratio):

echo 'scale=5;sqrt(1280^2+800^2)' | bc # 1509.43698

This will give the pixel diagonal length and with this value you can discover the physical horizontal and vertical lengths (and convert them to millimeters):

Note: This calculation works for monitors with square pixels; however, there is the seldom monitor that may compress aspect ratio (e.g 16:10 aspect resolution to a 16:9 monitor). If this is the case, you should measure your screen size manually.

Setting DPI manually

DPI can be set manually if you only plan to use one resolution (DPI calculator):

Note: while you can set any dpi you like and applications using Qt and GTK will scale accordingly, it's recommended to set it to 96, 120 (25% higher), 144 (50% higher), 168 (75% higher), 192 (100% higher) etc., to reduce scaling artifacts to GUI that use bitmaps. Reducing it below 96 dpi may not reduce size of graphical elements of GUI as typically the lowest dpi the icons are made for is 96.

DPMS

DPMS (Display Power Management Signaling) is a technology that allows power saving behaviour of monitors when the computer is not in use. This will allow you to have your monitors automatically go into standby after a predefined period of time. See: DPMS

Composite

The Composite extension for X causes an entire sub-tree of the window hierarchy to be rendered to an off-screen buffer. Applications can then take the contents of that buffer and do whatever they like. The off-screen buffer can be automatically merged into the parent window or merged by external programs, called compositing managers. See the following page for more info.

Sample configurations

Anyone who has an xorg.conf file written up that works, go ahead and post a link to it here for others to look at. Please do not in-line the entire configuration file; upload it somewhere else and link to it.

Tips and tricks

X startup (/usr/bin/startx) tweaking

The following options have to be appended to the variable "defaultserverargs" in the /usr/bin/startx file:

Enable deferred glyph loading for 16 bit fonts:

-deferglyphs 16

Note: If you start X with kdm, the startx script does not seem to be executed. X options must be appended to the variable "ServerArgsLocal" or "ServerCmd" in the /usr/share/config/kdm/kdmrc file. By default kdm options are:

Starting GUI Programs Remotely

To start up a program that uses X when logged in remotely (such as through ssh), you need to type this in from the remote login Bash shell:

export DISPLAY=:0

Then invoke the program the way you would locally from the shell.

Hint: Add that line to ~/.bashrc to have it happen automatically every time you log in.

On-Demand Disabling and Enabling of Input Sources

With the help of xinput you can temporarily disable or enable input sources. This might be useful, for example, on systems that have more than one mouse, such as the ThinkPads and you would rather use just one to avoid unwanted mouse clicks. Let's see how to accomplish this.

System-wide

Note: Using Gnome, an alternative would be to install the gnome-tweak-tool from extra. Within the Gnome Tweak Tool: Typing > Terminate and select the option Template:Keypress from the dropdown menu.
This reactivates the keyboard shortcut for killing the X server in Gnome.

Note: On KDE, this system-wide setting has no effect. To restore, go to Kickoff > Computer > System Settings which will open up the System Settings window. Click on 'Input Devices'. In this new window click the Keyboard tab and then click on the advanced tab. In this new window, click the box for 'Configure keyboard options.' Expand the entry for 'Key sequence to kill the X server' and ensure Template:Keypress is checked. Click Apply and close the System Settings window. You now have your Template:Keypress back in KDE.

Apple keyboard issues

Touchpad tap-click issues

Extra mouse buttons not recognized

X clients started with "su" fail

If you are getting "Client is not authorized to connect to server", try adding the line:

session optional pam_xauth.so

to /etc/pam.d/su. pam_xauth will then properly set environment variables and handle xauth keys.

Program requests "font '(null)'"

Error message: "unable to load font `(null)'."

Some programs only work with bitmap fonts. Two major packages with bitmap fonts are available, xorg-fonts-75dpi and xorg-fonts-100dpi. You do not need both; one should be enough. To find out which one would be better in your case, try this:

DRI with Matrox cards stops working

If you use a Matrox card and DRI stops working after upgrading to Xorg, try adding the line:

Option "OldDmaInit" "On"

to the Device section that references the video card in xorg.conf.

Recovery: disabling Xorg before GUI login

If Xorg is set to boot up automatically and for some reason you need to prevent it from starting up before the login/display manager appears (if the system is wrongly configured and Xorg does not recognize your mouse or keyboard input, for instance), you can accomplish this task with two methods.

From the GRUB menu, you can specify the runlevel in the kernel line by adding a number to the end of the kernel line specifying the run level you want. The following example sets the run level to 3:

kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/..ro 3

If you have not only a faulty system that makes Xorg unusable, but you have also set the GRUB menu wait time to zero, or cannot otherwise use GRUB to prevent Xorg from booting, you can use the Arch Linux live CD. Boot up the live CD and log in as root. You need a mount point, such as /mnt, and you need to know the name of the partition you want to mount.

You can use the command,

# fdisk -l

to see your partitions. Usually, the one you want will be resembling /dev/sda1. Then, to mount this to /mnt, use

# mount /dev/sda1 /mnt

Then your filesystem will show up under /mnt. From here you can delete the gdm daemon to prevent Xorg from booting up normally or make any other necessary changes to the configuration.

X failed to start : Keyboard initialization failed

If your hard disk is full, startx will fail. /var/log/Xorg.0.log will end with:

black screen, No protocol specified.., Resource temporarily unavailable for all or some users

X creates configuration and temporary files in current user's home directory. Make sure there is free disk space available on the partition your home directory resides in. Unfortunately, X server does not provide any more obvious information about lack of disk space in this case.