%general-entities; ]> $Date$ X Window System Components User Notes: Creating an X11R6 Compatibility Symlink Until recently (relatively speaking) almost every X Window installation you performed or came across was installed in the /usr/X11R6 directory. That was the standard for years. Developers picked up on this and wrote their package installation scripts looking for X in the standard location. Things have changed and the trend is to now install X in /usr. Some people want to install it in a custom location. Many package developers have not caught up to the change and their packages are still trying to find X in /usr/X11R6 and subsequently fail when you try to build the package. Though for most packages it is not difficult to 'hack' the installation script to fix the problem, that is not the long term solution to the problem. Upstream developers need to modernize their installation scripts and eliminate the problem altogether. Until then, you can create a symbolic link to satisfy the /usr/X11R6 requirement so that you won't be inconvenienced with a package build failure due to this known issue. If you wish to create the symlink, issue the following command as the root user (ensure you modify <$XORG_PREFIX> appropriately): ln -vsf <$XORG_PREFIX> /usr/X11R6 Configuring The X Window System As the root user create a basic X Window System configuration file with the following command: cd ~ && Xorg -configure /etc/X11/xorg.conf The screen will go blank and you may hear some clicking of the monitor. This command will create a file, xorg.conf.new, in your home directory. Edit the newly created configuration file to suit your system. The details of the files are located in the xorg.conf.5x man page. Some things you may want to do are: Section "Files". Change the order of the font paths searched. You may want to put 75dpi fonts ahead of 100dpi fonts if your system normally comes up closer to 75 dots per inch. You may want to remove some font directories completely. Section "Module". If you are going to install NVIDIA drivers, remove the "dri" line. Sections "InputDevice". You may want to change the keyboard autorepeat rate by adding . Section "Monitor". Specify the and values if the system does not automatically detect the monitor and its values. Section "Device". You may want to set some of the options available for your selected video driver. A description of the driver parameters is in the man page for your driver. Section "Screen". Add a DefaultDepth statement such as: . In the SubSection for your default depth, add a modes line such as: . The first mode listed will normally be the starting resolution. Test the system with the following command: X -retro -config ~/xorg.conf.new You will only get a gray background with an X-shaped mouse cursor, but it confirms the system is working. Exit with Control+Alt+Backspace. If the system does not work, take a look at /var/log/Xorg.0.log to see what went wrong. As the root user, move the configuration file to the new directory: install -v -m644 ~/xorg.conf.new /etc/X11/xorg.conf As the root user, create .xinitrc: cat > ~/.xinitrc << "EOF" # Begin .xinitrc file xterm -g 80x40+0+0 & xclock -g 100x100-0+0 & twm EOF This provides an initial screen with a small clock that is managed by a simple window manager, Tab Window Manager. For details of twm, see the man page. ~/.xinitrc Both the default, and the BLFS configuration for Xorg include xterm. Xorg's modular distribution no longer includes xterm, and as a result, the startx command will fail if you have not installed when using the modular X Window System. You can remove the xterm line in the above config file to test the xserver, or install one of the other terminal emulators and make appropriate changes. When needed, the X Window System creates the directory /tmp/.ICE-unix if it does not exist. If this directory is not owned by root, the X Window System delays startup by a few seconds and also appends a warning to the logfile. This also affects startup of other applications. To improve performance, it is advisable to manually create the directory before the X Window System uses it. Add the file creation to /etc/sysconfig/createfiles that is sourced by the /etc/rc.d/init.d/cleanfs startup script. cat >> /etc/sysconfig/createfiles << "EOF" /tmp/.ICE-unix dir 1777 root root EOF /etc/sysconfig/createfiles Start X with: startx and a basic functional X Window System should be displayed. Checking Direct Rendering Infrastructure (DRI) Installation DRI DRI is a framework for allowing software to access graphics hardware in a safe and efficient manner. It is installed in X by default if you have a supported video card. To enable direct rendering using the OpenGL implementation from (built separately with the "glx" and "dri" modules must be loaded. Additionally, the created device nodes in /dev/dri must have proper permissions for your users. A sample xorg.conf file might look like this: Section "Module" ... Load "glx" Load "dri" ... EndSection ... Section "DRI" Group "video" Mode 0660 EndSection The DRI devices are not accessible for any user except root and members of the video group. Add any users that might use X to that group: usermod -a -G video <username> DRI configuration may differ if you are using alternate drivers, such as those from NVIDIA or ATI. To check if DRI is installed properly, check the log file /var/log/Xorg.0.log for statements like: (II) R128(0): Direct rendering enabled If you elected to install the Mesa-Demos package when installing , from an xterm, run glxinfo and look for the phrase: direct rendering: Yes If direct rendering is not enabled, you can add verbosity by running LIBGL_DEBUG=verbose glxinfo. This will show the drivers, device nodes and files used by the DRI system. Again, if you have added the Mesa-Demos package, you can also run the test program glxgears. This program brings up a window with three gears turning. The xterm will display how many frames were drawn every five seconds, so this is a reasonable benchmark. The window is scalable, and the frames drawn per second is highly dependent on the size of the window. glxgears glxinfo For troubleshooting problems, check the DRI Users Guide at . Setting up Fonts There are two font systems in the X Window System. The first is the core X font protocol, and the second is Xft. Toolkits that use the core X font protocol include Xt, Xaw, Motif clones and GTK+-1.2. Toolkits that use Xft include GTK+-2 and Qt and use Fontconfig for control. Both font systems should be configured for proper font coverage in the X Window System. /etc/X11/xorg.conf Core X Font Protocol Core X Font Protocol The core X font protocol finds fonts from the server configuration file (xorg.conf). If no font paths exist in the configuration file, the server will fall back to an internal hard-coded path of $XORG_PREFIX>/share/fonts/X11. For each directory in the path, the server reads three files: fonts.dir - maps font files to font names; updated with mkfontdir fonts.alias - defines aliases (such as "9x18") for existing fonts fonts.scale - lists scalable fonts; updated with mkfontscale The core X fonts protocol uses names such as -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1. These fonts are rendered by the X server without antialiasing. The server itself uses the "cursor" font for painting the mouse cursor, and the protocol specification requires the font "fixed" to be available. Scalable fonts, such as Type1 and TrueType, are read from fonts.scale files by the server. The core X font system uses the "freetype" module for non-antialiased rendering of these fonts. Ensure that the "freetype" module is loaded in the xorg.conf file by adding it to the "Module" section: Section "Module" ... Load "freetype" ... EndSection The character set used is part of the font name, e.g. "-iso8859-1". It is important that applications which support a non-English interface specify the character set correctly so that the proper glyphs are used. This can be controlled through the X resources, which will be described later. In some cases, applications rely upon the fonts named "fixed" or something like "9x18". In these cases, it is important that the fonts.alias file specifies the correct character set. Users of ISO-8859-X encodings where X != 1 should modify the /usr/lib/X11/fonts/misc/fonts.alias file by replacing the "iso8859-1" string with the proper encoding name. This is accomplished by running the following command as the root user, substituting the proper value for <X>: sed -i 's,iso8859-1\( \|$\),iso8859-<X>\1,g' \ /usr/lib/X11/fonts/{75dpi,100dpi,misc}/fonts.alias Users of Cyrillic fonts have properly defined aliases in /usr/lib/X11/fonts/cyrillic/fonts.alias. However, this file will not be used unless the /usr/lib/X11/fonts/cyrillic directory is first in the font search path. Otherwise, the /usr/lib/X11/fonts/misc/fonts.alias file will be used. Xft Font Protocol TrueType Fonts Xft provides antialiased font rendering through Freetype, and fonts are controlled from the client side using Fontconfig. The default search path is /usr/share/fonts and ~/.fonts. Fontconfig searches directories in its path recursively and maintains a cache of the font characteristics in fonts.cache-1 files in each directory. If the cache appears to be out of date, it is ignored, and information is (slowly) fetched from the fonts themselves. This cache can be regenerated using the fc-cache command at any time. You can see the list of fonts known by Fontconfig by running the command fc-list. The X fonts were not installed in a location known to Fontconfig. This prevents Fontconfig from using the poorly rendered Type 1 fonts or the non-scalable bitmapped fonts. Symlinks were created from the OTF and TTF X font directories to /usr/share/fonts/X11-{OTF,TTF}. This allows Fontconfig to use the OpenType and TrueType fonts provided by X (which are scalable and of higher quality). Fontconfig uses names such as "Monospace 12" to define fonts. Applications generally use generic font names such as "Monospace", "Sans" and "Serif". Fontconfig resolves these names to a font that has all characters that cover the orthography of the language indicated by the locale settings. Knowledge of these font names is included in /etc/fonts/fonts.conf. Fonts that are not listed in this file are still usable by Fontconfig, but they will not be accessible by the generic family names. Standard scalable fonts that come with X provide very poor Unicode coverage. You may notice in applications that use Xft that some characters appear as a box with four binary digits inside. In this case, a font set with the available glyphs has not been found. Other times, applications that don't use other font families by default and don't accept substitutions from Fontconfig will display blank lines when the default font doesn't cover the orthography of the user's language. This happens, e.g., with Fluxbox in the ru_RU.KOI8-R locale. In order to provide greater Unicode coverage, it is recommended that you install these fonts: DejaVu fonts - These fonts are replacements for the Bitstream Vera fonts and provide Latin-based scripts with accents and Cyrillic glyphs. FreeFont - This set of fonts covers nearly every non-CJK character, but is not visually pleasing. Fontconfig will use it as a last resort to substitute generic font family names. Microsoft Core fonts - These fonts provide slightly worse Unicode coverage than FreeFont, but are better hinted. Be sure to read the license before using them. These fonts are listed in the /etc/fonts/fonts.conf aliases by default. Firefly New Sung font - This font provides Chinese coverage. This font is not listed in the /etc/fonts/fonts.conf aliases by default. Arphic fonts - A similar set of Chinese fonts to the Firefly New Sung font. These fonts are listed in the /etc/fonts/fonts.conf aliases by default. Kochi fonts - These provide Japanese characters, and they are listed in the aliases in /etc/fonts/fonts.conf by default. Baekmuk fonts - These fonts provide Korean coverage, and they are listed in the aliases in /etc/fonts/fonts.conf by default. The list above will not provide complete Unicode coverage. For more information, please visit the Unicode Font Guide. As an example, consider the installation of the DejaVu fonts. From the unpacked source directory, run the following commands as the root user: install -v -d -m755 /usr/share/fonts/dejavu && install -v -m644 *.ttf /usr/share/fonts/dejavu && fc-cache -v /usr/share/fonts/dejavu Setting up Keyboards In this version of X, non-Latin keyboard layouts do not include Latin configurations as was previous practice. To set up a keyboard for Latin and non-Latin input, change the XkbLayout keyboard driver option in the InputDevice section of the xorg.conf file. For example: Section "InputDevice" Identifier "Keyboard0" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "en_US,ru" Option "XkbOptions" "grp:switch,grp:alt_shift_toggle,grp_led:scroll" EndSection In this example, you can use the Alt+Shift combination to switch between keyboard layouts and use the Scroll Lock LED to indicate when the second layout is active. Using X Resources There are many options that can be set in X and X clients via resources. Typically resources are set in the ~/.Xresources file. The layout of the ~/.Xresources file consists of a list of specifications in the form of ~/.Xresources object.subobject[.subobject...].attribute: value Components of a resource specification are linked together by either tight, represented by a dot (.), or loose, represented by an asterisk (*), bindings. A tight binding indicates that the components on either side of the dot must be directly next to each other as defined in a specific implementation. An asterisk is a wildcard character that means that any number of levels in a defined hierarchy can be between the components. For example, X offers two special cursors: redglass and whiteglass. To use one of these resources, you need to add the following line: Xcursor.theme: whiteglass However, you can specify the background for all clients with: *background: blue More specific resource variables will override less specific names. Resource definitions can be found in the man pages for each respective client. In order to load your resources, the xrdb program must be called with the appropriate parameters. Typically, the first time resources are loaded, you use: xrdb -load <filename> To add resources to X's database in memory, use: xrdb -merge <filename> The xrdb instruction is usually placed in ~/.xinitrc or ~/.xsession. To get more information, see the xrdb man page. xrdb