xorg (Pete's Notes)

Web to the XFree86 home page.

Configure X for ibex's dual-head monitor

The Dell desktop has a nVidia GeForce FX 5200 with an adapter cable that splits the digital interface so it can drive the 2 Dell 1901FP monitors digitally. Once you've configured X to use the nvidia driver correctly, you can use the lspci command to see that Linux sees the two physical monitors as one "VGA compatible controller".

Get the NVIDIA driver

To get X to properly drive the Nvidia card in ibex, you have to tell X to load the proper video driver. First you have to get the proper driver. There are 2 ways to do it:

Get NVIDIA driver under Ubuntu Linux

Under Ubuntu, get the driver with
sudo apt-get install nvidia-glx-legacy
sudo gunzip /usr/share/doc/nvidia-glx/legacy/README.gz
sudo gunzip /usr/share/doc/nvidia-glx/legacy/nvidia-settings-user-guide.gz
sudo gunzip /usr/share/doc/nvidia-glx/legacy/examples/XF86Cenfig.sample.gz
I tried a reboot after this, but the system still didn't see the second monitor. I read the docs at /usr/share/doc/nvidia-glx/legacy/README.Debian. They suggest that you then run "sudo-nvidia-glx-config enable" to modify your /etc/X11/xorg.conf file, but I found it's better to hand-edit the file as described below.

Get NVIDIA driver under non-Ubuntu Linux

Web to nvidia and find the driver under Download Drivers->Download Drivers, then Graphics Driver, then GeForce and TNT2, then Linux IA32. As suggested in the nvidia Readme text, I disabled gdm by commenting-out the prefdm line in /etc/inittab. I then rebooted and got the console interface. Then I did
sh NVIDIA-Linux-x86-1.0-7667-pkg1.run
If it gives an error about not being able to find the kernel headers, do "yum install kernel-devel" and try again.

The installer couldn't find an appropriate kernel module, and couldn't find one at the nVidia site, so it said it would build one.

Then it said that my kernel was compiled to include rivafb support. Rivafb is incompatible with the nVidia driver. It said it would build the driver, but things will break if the rivafb module is ever loaded.

The installer built the driver successfully, but there were some messages about "module license 'NVIDIA' taints kernel".

Configure X and the NVIDIA driver

It took me a few hours of experimentation to get an xorg.conf file that handled the dual monitors correctly. I started with a sample xorg.conf and kept trying options from the documentation, restarting X, and then inspecting the error messages the /var/log/Xorg.0.log file. Finally, success! A working TwinView configuration. I kept a copy of the working one here. The remainder of this section describes the settings in that file.

I referred heavily to the documentation for the nvidia driver. Under Ubuntu, a little bit of information can be found in /usr/share/doc/nvidia-glx-legacy/README.Debian. The majority of information is in the NVIDIA Accelerated Linux Driver Set README and Installation Guide which is found at the Nvidia website under the README link.

By default, xorg loads the "nv" driver. To support dual monitors in hardware, you need to load the "nvidia" driver. In xorg.conf, in the "Device" section, set "Driver" to "nvidia".

Nvidia calls using two monitors "TwinView" mode. To enable it, you have to specify all of the following lines:

Option "TwinView"
Option "MetaModes"

Get XFree86

(as root)
cd /usr/src
mkdir XFree86-4.2.0
cd XFree86-4.2.0
ftp gate.ucar.edu
anonymous@ftp.xfree86.org
siemsen@ucar.edu
cd pub/XFree86/4.2.0/binaries/Linux-ix86-glibc22
get README
get Install
(from reading the Install file, the list of other files follows)
get Xinstall.sh
get extract
get Xbin.tgz
get Xlib.tgz
get Xman.tgz
get Xdoc.tgz
get Xfnts.tgz
get Xfenc.tgz
get Xetc.tgz
get Xvar.tgz
get Xxserv.tgz
get Xmod.tgz
exit
chmod +x Xinstall.sh
./Xinstall.sh
says to back up current X, so...
^C
tar cf /tmp/usr.x11R6.tar /usr/X11R6
tar cf /tmp/etc.X11.tar /etc/X11
./Xinstall.sh

home desktop

Check page 347 of the Red Hat Linux Secrets book for a little bit of information.

To get a decent display, you need to know what video card you have, and what monitor you have. My home system's video card is a "RAGE TURBO 8mb". To find out the chipset in the video card, run the SuperProbe program. On my home system, SuperProbe says the video card has the Mach64 chipset

Home system:
alias ss='startx -- -bpp 24'
Laptop:
alias ss='startx -- -depth 24 -auth $HOME/.Xauthority'
The xf86config program can't handle resolutions higher than 1280x1024. My home HP M90 monitor can do up to 1600x1200. To set up higher resolutions, hand-edit the /etc/X11/XF86Config file. Some of the values, like the modelines, are hard to figure out.

Use xvidtune. Play with it to fine-tune the display placement. Use the Show button to cause xvidtune to write the current settings to sysout, in a format suitable for cut/pasting into /etc/X11/XF86Config.

After much manual reading and testing, I found that I can get 1600x1200 from the lower color depths, like 16 and below. For 24, I can get up to 1280x1024. For 32, I can get up to 1024x768.

http://support.dell.com/docs/systems/pmojav/specs.htm. The external video port on the back of the laptop is used in at least two scenarios: when docked and when connected to the InFocus projector. In either case, the external video port has to be driven. When docked, the external video port has to be driven, but the laptop's LCD screen does not. When using the projector, the LCD screen and the external video port have to be driven at the same time. In either case, to drive the external video port, you have to modify the /etc/X11/XF86Config file to make the X server drive the internal and video correctly.

In the file, look for

Section "Device"
Identifier "NeoMagic (laptop/notebook)"

Uncomment the lines that say

Option "intern_disp"
Option "extern_disp"

This will make using the projector or the docking station monitor possible.

Configure X options

Start X at boot

I boot my laptop in different environments: Home, Work, Standalone, etc. In each environment, I have a different combination of screens and mouse types. For instance, when docked at work I use an external 1280x1024 monitor and an external 3-button mouse. When not docked, I use the laptop's built-in 1400x1050 monitor and the built-in 2-button touchpad.

If the laptop isn't configured for the correct environment, stupid problems occur. For instance, ff the wrong mouse type is selected, the external mouse won't work at all. If 3-button mouse emulation is set when it shouldn't be, HP OpenView won't handle right-button clicks correctly. If the screen resolution is wrong, windows will pop-up in the wrong places.

To fix this, when I boot I tell the laptop the environment I'm in, and it does the right thing. The environment is represented by a bash variable named SCHEME. When grub runs, it offers me a selection screen and starts the Linux kernel with the appropriate "SCHEME" variable set. Later, I source a bash script named /usr/local/bin/getscheme.sh whenever I need to know the environment that I'm in. Here's the contents of the script:

#!/bin/bash
#

# Get the "scheme", which is a value describing the machine's
# environment.  It reflects the choice made when the machine was
# booted.  The value is set in the /etc/grub.conf file, which sets the
# SCHEME kernel variable.  This is available in the /proc/cmdline file
# and can be used by the pcmcia module initializes, though as of
# 2003-06-06 I don't make use of it.  This function reads the
# /proc/cmdline file and sets a bash variable, and complains if
# anything unexpected happens.  IT DOES NOT SET AN ENVIRONMENT
# VARIABLE.

function getscheme() {
    local SCHEMEFILE=/proc/cmdline
    if [[ -r ${SCHEMEFILE} ]]; then
	SCHEME=`perl -e 'open F, "</proc/cmdline"; $_ = <F>; close F; /SCHEME=([a-z]+)/; print "$1\n";'`
	if [[ ${SCHEME} != 'home' && \
              ${SCHEME} != 'work' && \
              ${SCHEME} != 'ucarnet' && \
              ${SCHEME} != 'foreignnet' && \
              ${SCHEME} != 'standalone' && \
              ${SCHEME} != 'ucarnetv' && \
              ${SCHEME} != 'foreignnetv' && \
              ${SCHEME} != 'standalonev' ]]; then
	    echo "warning: SCHEME in ${SCHEMEFILE} not recognized"
	fi
    else
	echo "warning: ${SCHEMEFILE} not readable, setting SCHEME to \"unknown\""
	SCHEME='unknown'
    fi
}
    
By default, when a Red Hat system boots, init reads /etc/inittab which causes init to run /etc/X11/prefdm which runs gdm which reads /etc/X11/gdm/gdm.conf and then prompts for a username/password and then runs the XFree86 server, which reads /etc/X11/XF86Config. In this sequence, there's no way to feed a command-line option to XFree86.

To set up the screen and mouse correctly based on the environment, I need to give XFree86 a "layout" command-line option so it can select the right section of /etc/X11/XF86Config. There's no way to do this using gdm, so I disabled startup of gdm by commenting-out the prefdm line in /etc/inittab. Now, when the system boots, the X server isn't automatically started. Instead, I get a boring old text username/password prompt. I log in and start the X server manually.

To start the X server, I run aaa.sh, a script I wrote that runs startx, which starts XFree86 with a layout command-line argument. The value of of the argument comes from the SCHEME that I started the kernel with. Here's the contents of aaa.sh:

#!/bin/bash

. /usr/local/bin/getscheme.sh
getscheme

if [[ ${SCHEME} = 'home' ]]; then
    startx -- -layout Home
elif [[ ${SCHEME} = 'work' ]]; then
    startx -- -layout Work
elif [[ ${SCHEME} = 'ucarnet' ]]; then
    startx -- -layout Ucarnet
elif [[ ${SCHEME} = 'foreignnet' ]]; then
    startx -- -layout Foreignnet
elif [[ ${SCHEME} = 'standalone' ]]; then
    startx -- -layout Standalone
elif [[ ${SCHEME} = 'ucarnetv' ]]; then
    startx -- -layout UcarnetV
elif [[ ${SCHEME} = 'foreignnetv' ]]; then
    startx -- -layout ForeignnetV
elif [[ ${SCHEME} = 'standalonev' ]]; then
    startx -- -layout StandaloneV
else
    echo "unknown SCHEME in aaa.sh"
fi
    
This works well, though it requires the extra step of running aaa.sh every time I boot.

X resources

As of 2004-07-21, with the xorg 6.7 server and KDE on ibex, I don't have a .Xdefaults file. Instead, I have a .Xresources file, which is loaded at X startup by a script named ~/.kde/Autostart/PetesKdeStartup.sh.

To allow conditional setting of resources in the .Xresources file, add "-D`hostname`" to the xrdb command to define the name of the host. The .xinitrc startup script runs when X is started. It runs xrdb and feeds it the .Xdefaults file.

For some reason, in my home directory, .Xresources is a link to .Xdefaults. The .xinitrc script simply runs xrdb on both files if they exist, so it runs xrdb twice on the same file. To prevent this, comment-out the line in .xinitrc that runs xrdb on .Xdefaults.

Error and warning messages

Cannot convert string

If you get these messages when you start applications:
Warning: Cannot convert string "MetaCtrl<Key>Insert" to type VirtualBinding
then do this
xprop -root -remove _MOTIF_DEFAULT_BINDINGS
This works if you do it interactively. I was unable to get this to work when I put it in .xinitrc or aaa.sh.

wrong authentication

If you get
X11 connection rejected because of wrong authentication.
Then believe it or not, it may be because your /usr is full and the application can't create a Xauthority file.

error in locking authority file

If you get
error in locking authority file
Then believe it or not, it may be because your /usr is full and the application can't create a Xauthority file.

Startup programs

To get rid of the annoying help and file manager windows that Red Hat starts up by default, just log exit out of those windows, and then log out out of the window system as you normally would, by clicking on the Log out menu item. Then, select Save current setup before clicking the Yes button.

Colors

X colors are listed in /usr/X11R6/lib/X11/rgb.txt.

Mouse

3-button behavior

To get 3-button mouse emulation for when I'm undocked, in the "InputDevice" section of /etc/X11/XF86Config, I added
Emulate3Buttons
# Emulate3Timeout 50
This made the touchpad mouse buttons give me an emulated middle button. Unfortunately, when docked, it made the rightmost Logitech mouse button stop working in HP Openview (it works everywhere else). So I had to create two InputDevice sections in /etc/X11/XF86Config, one for the touchpad and one for Logitech mice at home and work. I use "-pointer" in ~/aaa.sh to conditionally select the mouse based on the boot SCHEME set when the system was booted (see my grub page). Note that to make HP Openview recognize the right mouse button, I had to remove the line that said "Option "ZAxisMapping" "4 5"" from the "Logitech" section.

Mouse wheel

See http://koala.ilog.fr/colas/mouse-wheel-scroll/ for info on how to get the mouse wheel to work in Netscape, xterms and XEmacs.

Mouse acceleration

Mouse acceleration is set in the ~/.xinitrc file. On the home system, the standard mouse acceleration is annoying to DeLynn. To fix it, do
xset m 6

X fonts

Red Hat 7.2 installs uses the xfs font server. It's config file is /usr/X11R6/lib/X11/fs/config. This is where the font path is defined. I need both 75dpi and 100dpi fonts, because the laptop display is 72x72 and the external 17 inch NEC monitor is 96x96.

I checked that all font diregtories listed in the /usr/X11R6/lib/X11/fs/config actually exist. /usr/X11R6/lib/X11/fonts/cyrillic didn't, so I deleted it.

I added a font directory to the path as described in the Abiword page.

Old instructions for installing XFree86

cd /usr/src
mkdir XFree86-4.1.0
cd XFree86-4.1.0
ftp gate.ucar.edu
anonymous@ftp.cs.umn.edu
siemsen@ucar.edu
cd pub/XFree86/4.1.0
get Xinstall.sh
^Z
bg
sh Xinstall.sh -check
fg
cd binaries/Linux-ix86-glibc21
get Install
^Z
bg
read the Install file
fg
binary
get Xinstall.sh
get extract
get Xbin.tgz
get Xlib.tgz
get Xman.tgz
get Xdoc.tgz
get Xfnts.tgz
get Xfenc.tgz
get Xetc.tgz
get Xvar.tgz
get Xxserv.tgz
get Xmod.tgz
get Xflat2.tgz
get Xhtml.tgz
quit
mv ../Install .
cd /usr
tar cf /usr/X11R6-3.3.6.tar X11R6
gzip X11R6-3.3.6.tar
log out, exit X, and log in as root
cd /usr/src/XFree86-4.1.0
sh Xinstall.sh

This'll install local HTML docs in /usr/X11R6/lib/X11/doc/html/index.html, so put a link to them into the home web page.

For the new X server to work, you have to have a new XF86Config file, with the new syntax. To get one, I did this as root:

XFree86 -configure
mv /root/XF86Config.new /etc/XF86Config

This allowed the new server to run, but with poor color support. To get good color support, edit the .bashrc file and define

alias ss='startx -- -depth 24 -auth $HOME/.Xauthority'

This fixed the color problem, and set up xauth-style security so that exmh will run (see exmh.html for details of this)..

After you start it up, the /var/log/XFree86.0.log file gives a detailed listing of what happened during startup. This can be studied for ways to tune the /etc/XF86Config file.


Address comments or questions about this Web page to the Network Engineering & Technology Section at nets-www@ncar.ucar.edu. The NETS is part of the Scientific Computing Division of the National Center for Atmospheric Research, which is part of the University Corporation for Atmospheric Research.
Last modified: Mon Jul 10 17:44:50 MDT 2006