More then two years ago I wrote a post on how to migrate to X with HAL, evdev and RandR and get rid of unneeded settings. Today I will share with you how to migrate X from HAL to udev and get rid of unneeded XML clutter.

In case you use Gentoo and have recently updated X and found out your graphical envorinment is suddenly not working (as it should), that is because now in Gentoo – I suppose other distributions have or will follow soon – x11-base/xorg-server-1.9 and with it the rest of X11R7.6 is in the stable tree for most architectures. Since the previous stable (in Gentoo) version X11R7.5 included x11-base/xorg-server-1.7 this is a big leap. HAL was dropped in favour of pure udev, and XCB has been made a requirement (the latter does not influence your settings).

This migration took me quite a few hours to get right, so I decided to summarise it below.

Status quo before the migration

I suppose your system before the migration looks very much like mine.

You keep all your needed display and general X settings which are different from the defaults in /etc/X11/xorg.conf and it looks pretty spartan already. If this is not the case and your xorg.conf file is full of clutter, see my previous HOWTO on how to clean it up (but skip the bits about HAL).

So far (in X11R7.5) if you needed any special settings for any input devices – like non-US keyboard layout, special key mapping for your very button-rich mouse or tweak your touchpad – you used HAL for hotplugging these devices and stored their settings in .fdi files in the /etc/hal/fdi/policy/ directory. This is what we will be getting rid off. But have no fear, you will still be able to hot plug your devices and better yet, the settings will be a lot easier to read and write.

Remember that X comes with autodetection, hotplugging and pretty smart defaults. So to keep everything neat and tidy, at first try how things work if there are no setting files whatsoever present. And only if you want to change the settings different from the defaults, create them.

Migrating the display settings

The display settings are the easiest to migrate, since the same syntax is used.

While it is possible (again) to use just /etc/X11/xorg.conf to store all X-relevant settings, including the input devices, my advice is to break it down into smaller files that reside in the /etc/X11/xorg.conf.d directory. In it you can name the files whatever you like, but since the files are read in the alphabetic order, by convention most people use two-digit numbers as prefixes.

For this reason I created /etc/X11/xorg.conf.d/10-display.conf which reads:

Section "Monitor"
        Identifier            "Faunusov LCD"

        DisplaySize            304 190
EndSection

Section "Device"
        Identifier            "Integriran Intel GMA 4500 MHD"

        Driver            "intel"

        Option    "XvMC"            "true"
EndSection

Section "Screen"
        Identifier            "Primarni zaslon"

        Device            "Integriran Intel HD"
        Monitor            "Faunusov LCD"
        DefaultDepth            24

    SubSection "Display"
            Depth            24
    EndSubSection

EndSection

I actually achieved this by a simple mv /etc/X11/xorg.conf /etc/X11/xorg.conf.d/10-display.conf because I already kept only display-related settings in there.

I set the DisplaySize entry, because sometimes KDE (and other X applications) needs the physical size of the display in order to calculate what the real DPI is.

The XvMC option is off by default, so I turned it on to try if I get (stable) video acceleration when playing movies on my Intel GMA 4500 MHD.

I put the Driver entry there because it pains me to see in /var/log/XOrg.0.log that X is trying the vesa and fbdev drivers before it finds intel module.

Update

Later on I figured out that all the settings I put into /etc/X11/xorg.conf.d/10-display.conf already get automatically enabled (even the display size is guessed right), so I removed this file as well. X is getting smarter and smarter, eh?

Migrating the keyboard

Next in line is of course the keyboard.

I think now is the best time to explain a bit about the new syntax. Basically it looks identical to the one which was used for xorg.conf since pretty much forever, but with a few new additions.

The first is the InputClass section – in it you can include everything you did so far in the InputDevice section, but also some new ones which are there to make hotplugging and autodetection work. I think it is for the best if I explain it in an example…

If you have ever set up X by hand before, my /etc/X11/xorg.conf.d/20-keyboard.conf will look quite familiar:

Section "InputClass"
        Identifier            "Tipkovnica"

        MatchIsKeyboard        "true"

        Driver             "evdev"

        Option    "XkbLayout"        "si"
        Option    "XkbOptions"        "terminate:ctrl_alt_bksp"
EndSection

Attention

Be sure to change the XkbLayout option to the appropriate two-letter country code of the layout you want to use on your keyboard.

Now you can see the second newcommer – Match* entries are now used to match which devices should use these settings.

In the above example MatchIsKeyboard every input device that udev declares as "Keyboard" will use these settings. In the same way you can use MatchIsPointer for mice, MatchIsJoystick for joysticks, MatchIsTablet for tablets, MatchIsTouchpad for touchpads and MatchIsTouchscreen for touchscreens.

Similar, but different insofar as that their parameters are not boolean but strings, are:

  • MatchProduct which can contain a part of the device's product name;
  • MatchVendor part of the device's vendor name;
  • MatchDevicePath which matches the device's file path;
  • MatchOS which matches the OS;
  • MatchPnPID which matches the device's PnP ID;
  • MatchUSBID which matches the devices USB ID (you can obtain it by running lsusb – very practical!);
  • MatchDriver which matches the driver the device currently uses; and
  • MatchTag which matches tags if they have been assigned by the backend.

Since there are so many, I have emphasised the most practical ones for your convenience.

These settings stack now, so if you have more then one keyboard or could set up the driver and layout for all the keyboards at the same time using the above example (since it matches all keyboards); but for each single (or group of) keyboard make additional settings. Of course this applies to all other input devices.

Also, it is possible now to make X ignore a device – just write an InputClass section with the appropriate Match* entries to catch it and add Option "Ignore" "true".

Oh, and at the bottom there is that extra treat I promissed – If you missed that for quite some time now you could not restart or "zap" your X with Ctrl+Alt+Backspace, Option "XkbOptions" "terminate:ctrl_alt_bksp" enables it.

Mice

The other device that you commonly use in X are of course mice and other pointing devices. On my ThinkPad T400s I quite extensively use the touchpad and the trackpoint, but for more exact use like drawing and gaming I sometimes use the Logitech NX80 mouse.

The settings for my touchpad and trackpoint reside in: /etc/X11/xorg.conf.d/30-touchpad.conf:

Section "InputClass"
        Identifier            "TouchPad"

        MatchIsTouchpad         "true"

        Driver            "synaptics"

        Option    "VertEdgeScroll"    "true"
        Option    "HorizEdgeScroll"    "true"

        Option    "VertTwoFingerScroll"    "false"
        Option    "HorizTwoFingerScroll"    "false"

        Option    "CircularScrolling"    "true"
        Option    "CircScrollTrigger"    "8"

        Option    "Emulate3Buttons"    "false"
EndSection

As you can see, this example matches all touchpads, since I am quite confident I will not add any new touchpads to my laptop. If there were more then one possible matches I would match the per-device specific settings with stricter rules (see the example below).

Because it is a touchpad I also associated the synaptics driver with it instead of the generic evdev. The reason is that evdev does not handle touchpads as well as synaptic does (yet).

From the settings you can see that I have enabled both edge scrolls and disabled the two finger scrolling. I also enabled circular scrolling and set it so it triggers if I start drawing circles from the upper left corner of the touchpad. If you have huge texts to scroll, do give circular scrolling a try – I find it a great improvement!

If you use KDE and have noticed that whatever you define in the X settings for your touchpad does not work in KDE, check if under System Settings → Keyboards and Mice you see a Touchpad settings. If this is the case and you would rather have the same settings in all WM and DE, just emerge -c kde-misc/kcm_touchpad on Gentoo (in other distributions uninstall it using the package manager).

As the last piece in the puzzle in /etc/X11/xorg.conf.d/40-logitech-usb-mouse.conf reside the settings for my Logitech NX 80:

Section "InputClass"
        Identifier            "Logitechova miška s preveč gumbi"

        MatchIsPointer        "true"
        MatchVendor        "Logitech"
        MatchUSBID        "046d:c521"

        Driver                "evdev"

        Option    "ButtonMapping"            "1 0 3 4 5 6 7 8 2"
EndSection

Because this is a rather unique mouse, since it does not have a middle mouse button, I have disabled it (see "0" where "2" should be) and remapped it to button 9 (which exists).

Of course I would not dream of disabling the middle mouse button on any other mouse I come accross, so I made sure the udev and X only match these settings to this very mouse. With lsusb -v I found out the USB ID and idVendor, which I matched. (I would have used idProduct as well, but since I have this mouse it has changed at least once and still is not the same as on the label).

Just for illustration, this is how the same mouse was set up when I used HAL:

<?xml version="1.0" encoding="UTF-8"?>

<deviceinfo version="0.2">
    <device>
        <match key="info.capabilities" contains="input.mouse">
        <match key="info.product" contains="Logitech USB Receiver">
            <merge key="input.x11_driver" type="string">evdev</merge>
            <merge key="input.x11_options.ButtonMapping" type="string">1 0 3 4 5 6 7 8 2</merge>
        </match>
        </match>
    </device>
</deviceinfo>

An observant eye will quickly notice where the similarities between the two syntaxes are.

If you used many or long and complex .fdi files in the past with not too much effort you can translate them into the new (or rather revised ancient) syntax of X11R7.6.

Cleaning up

After you migrated all the settings to the new X11R7.6 + udev way, you can safely remove:

– the file /etc/X11/xorg.conf (unless you migrated your settings into that file instead of the directory); and – the appropriate .fdisettings files stored in the /etc/hal/fdi/policy/.

Extra information

For more information see:

hook out → woo, that was a big one

Share on: TwitterFacebookEmail


Related Posts


Reading Time

~8 min read

Published

Category

Tehne

Tags

Stay in Touch