Blog karp0tt

GNU/Linux configurations

xorg, hal, udev && Touchpad/Mouse Toggle (>=xorg-server-1.5 < xorg-server-1.8)

I read, there were some changes between <xorg-server-1.5 and >=xorg-server-1.5. While I’ve updated my version to the latest possible (x11-base/xorg-server-1.6.0), I thought of using hal for my keyboard/touchpad/mouse-configuration.
The following configuration works for me:

First and foremost we need evdev configured in the kernel:

Device Drivers --->
  Input Device Support --->
     <*> Event Interface

which results as the following in the related .config:
After this the new kernel will be needed, so we issue:
(sudo) init 6

Now, edit /etc/make.conf to the following:
INPUT_DEVICES=”evdev synaptics”
Yes, there is no keyboard or mouse present, because evdev now handles all the keyboard/mouse-input.

Now we need to emerge the newest xorg-server with the hal-useflag enabled. Since there are other packages, that depend on hal with this change, we enable it globally:
echo ‘USE=”$USE hal”‘ >> /etc/make.conf

After this, a full world-update is required to let the system know, that there’ve been changes to the global useflags.
emerge -avuDN (@)world
(I’m bracketing the at, because at this moment >=sys-apps/portage-2.2_pre is masked due to known bugs.)

While the world-update is running, we can start writing our own hal-policy-files. :]
(If you’ve got no UTF-8-Support on your system change the encoding to the one you’re using)

If hal was already installed, the following can be used, else just edit a correspondent file in your home/root-directory and copy it afterwards.
I just copied /usr/share/hal/fdi/policy/10osvendor/10-x11-input.fdi to /etc/hal/fdi/policy/10-x11-input.fdi and changed it, so that the right layout and variant are being used:
[~]# cat /etc/hal/fdi/policy/10-x11-input.fdi

The following is my policy-file for the Touchpad, formerly known as InputDevice “Touchpad”:

[~]# cat /etc/hal/fdi/policy/11-x11-synaptics.fdi

And this one is the new xorg.conf
[~]# cat /etc/X11/xorg.conf
Section “ServerLayout”
Identifier “ Configured”
Screen 0 “Screen0” 0 0


Section “ServerFlags”
Option “AllowEmptyInput” “true”
Option “AutoAddDevices” “true”
Option “AutoEnableDevices” “true”

and delete all Sections named “InputDevice”.

After the world-update is finished, we need to add hald to start while the machine boots. Therefore we execute the following command as root:
rc-update add hald default

There are only two commands left and we’re ready to use our new xorg-server with it’s now drastically reduced xorg.conf (106 lines to at first 97 [switched from ati-drivers (proprietary) to xf86-video-ati (open-source)] and finally 61 [I actually configured everything I would ever use for my touchpad in my xorg.conf, ignoring synclient]) and those new hal-rules.
Again, as root:
/etc/init.d/hald start
(or restart hal, if it’s already been started, so that it uses the new rules. At the moment hal doesn’t recognize changed rules while it’s running, I hope, the devs are going to change this one in the future)
/etc/init.d/xdm restart

If you’ve done everything right so far, there should be your login-screen, so you can logon without any further problems.

Right now, you should use the following command, to find out, if the Touchpad-policy-file has been recognized from the X-Server:
/usr/bin/synclient -l
If you’re getting
Can’t access shared memory area. SHMConfig disabled?
then change the following in /etc/hal/fdi/policy/11-x11-synaptics.fdi:
From <merge key=”input.x11_options.SHMConfig” type=”string”>true</merge>
to <merge key=”input.x11_options.SHMConfig” type=”string”>On</merge>

At first I’ve tried the second line, but then I got the SHMConfig disabled? error and tried the first one. After that, it worked wonderfully.

Now we’re using udev to turn off the touchpad, when there’s an external mouse attached:

[~]# cat /etc/udev/rules.d/10-local.rules
ACTION==”add”, SUBSYSTEM==”input”, ENV{ID_CLASS}=”mouse”, RUN+=”/usr/bin/synclient TouchpadOff=1″
ACTION==”remove”, SUBSYSTEM==”input”, ENV{ID_CLASS}=”mouse”, RUN+=”/usr/bin/synclient TouchpadOff=0″

Since udev is recognizing new or changed rules, while it’s running, you don’t need to restart the udev-daemon.

I myself doubted at the beginning, that this route, the xorg-devs took, would be a good one, but after taking a little time in reading some wiki-entries and postings on the web, I now think, it was a good decision, leaving everything input related to hal (for hotplugging issues) and using the xorg.conf only for tuning the X-server.


Written by body0r

April 7, 2009 at 7:00 pm

12 Responses

Subscribe to comments with RSS.

  1. Thanx man!


    April 12, 2009 at 10:41 pm

  2. […] The next task was getting X11 up and running. The latest versions of X leans heavily on hal, and gentoo has really dropped the ball here. I installed gnome-desktop with the assumption that it would pull in X11. Not only did I have to install X11 separately, but X11 left out hal, which is now required to connect X11 to input devices. I ended up wasting a couple of hours this morning rewriting xorg.conf line by line and searching the internet for clues as to why the mouse and keyboard would work in the console but not in X. I finally came across this post, and then in more depth here. […]

  3. I have the same problem, it’s an old machine so I don’t emerge -uDNv world often. Was quite surprised when there would just be no input after the upgrade. Several other recipes didn’t work, so I hope it’ll be ok with this one.

    Good thing I’ve got backups and a spare Kubuntu on my other hdd. I love my gentoo, once everything is set up it works well. But every update, be it kernel or just the userland, can be the source for major fuckups…


    May 26, 2009 at 6:26 pm

  4. I has a big problem with this issue. With xorg-server 1.5.3 all the xorg configuration with fdi files runs correctly, but when I upgrade xorg-server to the 1.6.X version, the keyboard and mouse don’t rule :S. I Finally downgrade the xorg-server version :(


    August 6, 2009 at 1:51 pm

  5. I can run synclient -l from within gnome/X, but when I run it from a root terminal outside X, I get “Failed to connect to X server”. What is wrong?

    daniel nilsson

    January 7, 2010 at 3:35 pm

    • there is nothing wrong, synclient needs the variable $DISPLAY, which is set by any running x-server


      January 7, 2010 at 6:14 pm

      • How do I extract this variable from the running xorg server without needing to hardcode it? Neither root nor my normal user has $DISPLAY defined.

        daniel nilsson

        January 7, 2010 at 7:04 pm

      • echo $DISPLAY from a terminal within the running X-Session
        then (mostly :0)
        export DISPLAY=:0 in one of the ttys and that’s it


        January 7, 2010 at 9:07 pm

      • I have tried defining DISPLAY to be the value the x-server is using, the only difference I get is this output:

        synclient -l
        No protocol specified.
        Failed to connect to X server.

        Could this have anything with permissions, xauth or similar to do?

        daniel nilsson

        January 7, 2010 at 11:02 pm

      • >>Could this have anything with permissions, xauth or similar to do?
        That could be the case, I just tried it (synclient -l with DISPLAY set) and I get the same error

        Well since I’m not even trying to use my mouse or touchpad outside of X, I don’t have any problems with that :>


        January 9, 2010 at 12:37 am

      • The problem is that udev runs outside X, so I need to get synclient working for that. Now I have resorted to having two buttons in gnome that set the touchpad on/off for now.

        daniel nilsson

        January 9, 2010 at 11:10 pm

  6. […] a comment » One year after outsourcing those input devices from my xorg.conf to hal, I think those xorg developers are toying with me. […]

Comments are closed.

%d bloggers like this: