Linux peripheral devices configuration

This weekend I tried to get my new keyboard (Microsoft Ergonomic Keyboard 4000) and my Logitech MX1000 Laser mouse to work properly. The Keyboard has many extra-keys I didn’t bother to count, and the mouse has 12 buttons which can be very useful at times.

Almost accidently I solved a bugging performance problem with the Firefox browser. It was incredibly slow when opening Google Spreadsheets, well the whole system was incredibly slow while loading the spreadsheet… .

Configuring the Microsoft Ergonomic Keyboard 4000 and the MX1000 Laser mouse

Most of the information I used to get my new keyboard working (except of 6 keys) came from the Gentoo-Wiki and the Ubuntu-Forum.

What you need is the

Make sure that you get the right version of the patch for your Kernel (in case that 2.6.22 is outdated).

Extract the Kernel, patch it (patch -p1 < hid.patch) and compile it. I assume you’ve got some experience compiling a Kernel (just follow the instructions at the Ubuntu-Forum).

Now for the configuration, I didn’t follow the Gentoo-Wiki guide and didn’t hack my xkb configuration because I couldn’t see any advantages… it seems that the “evdev” XkbModel does the right thing (if you don’t set the Model to evdev, the keys are really messed up).

I used the Gnome Keyboard-Shortcuts program to assign functionality to the keys. The keys I couldn’t get to work are the special keys 1, 2, 3, 4, 5, Fav, and Zoom-In (Zoom-In is recognized by X, but is already assigned). Since I use GMail for mail I assigned the Mail-button to firefox "http://www.gmail.com".

The mouse is equally simple, follow the instructions here.

Here the /etc/X11/xorg.conf config (relevant parts):

Section "InputDevice"
    Identifier     "Keyboard Ergo. 4000 1"
    Driver         "evdev"
    Option         "Protocol" "evdev"
    Option         "Device" "/dev/input/event1"
    Option         "CoreKeyboard"
    Option         "XkbRules" "xorg"
    Option         "XkbModel" "evdev"
    Option         "XkbLayout" "us"
EndSection

Section "InputDevice"
    Identifier     "Keyboard Ergo. 4000 2"
    Driver         "evdev"
    Option         "Protocol" "evdev"
    Option         "Device" "/dev/input/event2"
    Option         "XkbRules" "xorg"
    Option         "XkbModel" "evdev"
    Option         "XkbLayout" "us"
EndSection

Section "InputDevice"
    Identifier     "MX1000"
    Driver         "evdev"
    Option         "CorePointer"
    Option         "Device" "/dev/input/event0"
    Option         "Buttons" "12"
    Option         "Resolution" "800"
EndSection

[...]

Section "ServerLayout"
    Identifier     "Default Layout"
    Screen         "Default Screen" 0 0
    InputDevice    "Keyboard Ergo. 4000 1" "CoreKeyboard"
    InputDevice    "Keyboard Ergo. 4000 2" "SendCoreEvents"
    InputDevice    "MX1000"
EndSection

The udev rules to fix the keyboard to event1 and event2 (/etc/udev/rules.d/10-nek4k.rules, the UID should not differ from yours):

KERNEL=="event*",SYSFS{modalias}=="usb:v045Ep00DBd0173dc00dsc00dp00ic03isc01ip01", MODE="0644", NAME="input/event1"
KERNEL=="event*",SYSFS{modalias}=="usb:v045Ep00DBd0173dc00dsc00dp00ic03isc00ip00", MODE="0644", NAME="input/event2"

The udev rules for the mouse (/etc/udev/rules.d/11-mx1000.rules):

KERNEL=="event*",SYSFS{modalias}=="usb:v046DpC50Ed2500dc00dsc00dp00ic03isc01ip02", MODE="0644", NAME="input/event0"

The ~/.xbindkeysrc configuration I use simply activates the “Forward” “Backward” functionality (thumb buttons):

# Backward and Forward buttons
"xvkbd -text "\[Alt_L]\[Left]""
  m:0x10 + b:8
"xvkbd -text "\[Alt_L]\[Right]""
  m:0x10 + b:9

This maps the mouse button 8 to Alt-Left, and button 9 to Alt-Right. Remember to start xbindkeys at the start of you session (for example add it to .gnomerc or even better to .xprofile).

To rearrange the mouse buttions how I like them, I use a Xmodmap file (/etc/X11/Xmodmap):

!MX1000
pointer = 1 10 3 4 5 7 6 8 9 2 11 12 14 13

This rearranges the second button (middle button on the scroll-wheel) to the thumb button, and reverses the tilt-buttons of the scroll-wheel. This could also be in .xmodmaprc.

Use xev to find out which number any button has (works for the keyboard too).

Performance issues with Firefox

I noticed severe performance issues with Firefox each time I opened a Google Spreadsheet. The interesting thing was that Xorg took 100% of the CPU, not Firefox itself. I resolved the issue more or less accidently: I installed the binary NVidia driver which gave the whole system a real performance boost.

Bootup Performance

The next thing I attacked was the boot-time. First I disabled many services I didn’t use. Usually I create a folder called disabled within the runlevel directories (/etc/rcS.d and /etc/rc2.d) and move the services I don’t use (or don’t know I use).

Using a coll utility called BootChart (stores it’s charts in /var/log/bootchart/) I found out that a big chunk of my startup time is taken by getting my IP by DHCP. I changed my configuration to a static IP, so I could reduce the startup time by 10 seconds.

My chart currently shows a lot of time (and I/O access) is coming from modprobe, I wonder if compiling the Kernel with all necessary drivers included into the Kernel would give me even less startup time… Maybe I’ll try that sometime too :-).

So, now my Ubuntu setup seems quite nice, unfortunately I edited a lot of files in the process, which are easily lost so this is more or less a tutorial for my future-me to get the stuff working again.

It’s also perhaps the most stupid Unix design idea of all times. Unixis really nice and well done, but think about this a bit: ’For everyfile that is read from the disk, lets do a … write to the disk! And,for every file that is already cached and which we read from the cache… do a write to the disk!
Linus Torvalds about atime