udev: Disabling touch pad when there’s an external mouse

Thursday, September 6th 2007

My hands are big and unwieldy. My touch pad is hyper sensitive. Together they make a mess of everything I do: the pointer jumps back and forth on the screen like some horny bonobo, and it makes my blood boil.

Easy solution

Turning the touch pad off is easy: synclient TouchPadOff=1.

But having to issue that command all the time is not very elegant, and I’d like the computer to do it by itself. I’m already using an external mouse most of the time, so this is just the matter of turning off the touch pad whenever the mouse is connected. For this we need

  1. to enable synclient,
  2. a short udev script to catch plugging and unplugging and
  3. a short shell script to run synclient

Enabling synclient

synclient is an interface to the Synaptics TouchPad driver. It won’t work until you’ve enabled SHMConfig "on" in the XOrg configuration (usually /etc/X11/xorg.conf). But this is not multi-user safe (from the synclient man page):

WARNING: This is not secure if you are in an untrusted multiuser environment. All local users can change the parameters at any time.

Catch the plug events

On contemporary lunix systems, udev monitors hardware connects and disconnects. This small snippet will run our shell script whenever an external mouse is plugged or unplugged:

KERNEL=="mouse[0-9]*", SUBSYSTEM=="input", RUN="/usr/local/bin/plug_external_mice $devpath"

Add this to your local file /etc/udev/rules.d/10-local.rules (create it if it doesn’t exist).

Manipulate the touch pad

Put this into /usr/local/bin/plug_external_mice and make it executable ( chmod +x /usr/local/bin/plug_external_mice ):

#!/bin/bash
# read http://reactivated.net/writing_udev_rules.html
## uncomment this for debugging:
#echo $ACTION-ing $@ >> /tmp/usb-mice-plug.log
case "$ACTION" in
  remove) /usr/bin/synclient TouchpadOff=0 ;;
  add) /usr/bin/synclient TouchpadOff=1 ;;
esac

This will turn the touch pad off when you connect the external mouse, and back on when you remove it.

Taking it further

Ideally, there shouldn’t be any need for an external bash script. But, for some reason, these rules won’t work:

SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION="add", RUN="/usr/bin/synclient TouchpadOff=1"
SUBSYSTEM=="input", KERNEL=="mouse[0-9]*", ACTION="remove", RUN="/usr/bin/synclient TouchpadOff=0"

I have no ideas why. If you do, please let me know!

debunk2 now writes vCard

Thursday, January 11th 2007
The debunk program is now able to export to properly encoded vCards (vcf files) -- an electronic business card. What does this mean? Well, importing into different email programs just got a lot easier, since the vCard format is more *suited for such things*. This is what it looks like now: debunk2-vCard It still doesn't install easily on Windows, which is a bummer. Get it here: code.google.com/p/debunk2

debunk2 -- nk2 reader

Thursday, January 4th 2007
I've gone ahead and created a program to extract email addresses and names from Outlook's NK2 files. And what, exactly are NK2 files? It's the files that store Outlooks autocomplete data. From the project page: debunk2 Read MS Outlook autocomplete (NK2) files and extract email addresses
Microsoft Outlook stores its autocomplete email info in an undocumented file format. This project tries to unlock the information therein.
I've even had a go at documenting the file format. It's not pretty, it's not very accurate, but at least it does get to the important stuff inside of the file. And that's the purpose of reverse engineering, isn't it? Yea, I know, the name sucks.

Kubuntu Breezy and the hungry gam_server

Thursday, February 23rd 2006

I started noticing some days ago that some applications seemed to slow the system down significantly. More specifically, every time I ran digikam, it felt like running through maple syrup.

A quick look at top revealed that a process called gam_serverwas merrily eating up 10%-20% of cpu capacity. Of course, I killed it straight away. But alas! Like a bird phoenix, it was up in no time, doing central processing like nothing happened.

So I turned to the internet. I read about [gamin], and I read about a possible solution to my woes. 10 minutes later, *gam_server is not giving me such a hard time* anymore. Here's what I did.

  1. Installed gamin from dapper, as per spilog's suggestions
  2. Installed a new ~/.gaminrc configuration file, from the gamin pages
  3. killall gam_server

What does my gaminrc look like?

# configuration for gamin
# http://www.gnome.org/~veillard/gamin/config.html
#
# Can be used to override the default behaviour.
# notify filepath(s) : indicate to use kernel notification
# poll filepath(s)   : indicate to use polling instead
# fsset fsname method poll_limit : indicate what method of notification for the filesystem
#                                  kernel - use the kernel for notification
#                                  poll - use polling for notification
#                                  none - don't use any notification
#
#                                  the poll_limit is the number of seconds
#                                  that must pass before a resource is polled again.
#                                  It is optional, and if it is not present the previous
#                                  value will be used or the default.

# this is where I keep my pictures and my music, use kernel notification on these paths:
notify /mnt/felles/bilder* /mnt/felles/musikk*

More reading

picking on dnotify

Wireless loonix on MSI Mega 180

Wednesday, January 26th 2005

I write this on a MSI Mega 180 DeLuxe. It stocks a WLAN chip (you know, IEEE80211b and whatnot), which for the driver has been opensourced. So, clever guys are working to include it, but the driver is not yet part of the mainline linux distribution. This means that it's not included on installation sets from various distributors. Which is sad when wireless's all you've got.

So what, you say?

I'll tell you. I am blessed with the opportunity to try out three current linux distributions on behalf of a Norwegian linux mag, and I'm about to tell you how to set up this driver under the different flavors.

For all variants, you obviously need the driver source. I'm writing this using the 1.2.1 version, if there's something newer you should probably use that, but in that case this guide obviously won't matter any more, so go do something else.

First off, the bloody French:

Mandrake Powerpack 10.1 Official.

  • Make sure you install the kernel-source package, and the gcc package and all their dependencies.
  • Untar the archive, enter the Module subdirectory and say make && make install
  • Go to the Mandrakelinux Control Center, find Network and Internet and add a new device. Make sure it's wireless. Enter the info. Don't worry if things don't seem totally all right yet.
  • Reboot. I know, it's silly to go rebooting, but Mandrake won't notice the driver if you don't.
  • Return to the Control Center, and activate the device. This one did it for me.

Turning over to the land of the brave:

Fedora Core 3

  • Make sure you've got the kernel source package and the gcc package, but Fedora installs them by default, so you've probably got it.
  • Untar the archive, enter the Module subdirectory and say make && make install
  • Don't go running for the beach just yet. First, stick the following info into a new file called /etc/sysconfig/ifcfg-ralink:
 DEVICE=ra0
 ONBOOT=yes
 BOOTPROTO=dhcp
 USERCTL=no
 PEERDNS=yes
 TYPE=Wireless
 IPV6INIT=no

Why this, you say? Because Fedora wants all networking devices to be called ethN, the rt2400 driver people don't (their device is called ra0), and then you and I are left to sort the mess. So we trick Fedora to think she configured ra0 by herself.

  • Enter System Settings, select Network, create a new device, select Wireless and follow the wizard. Make sure you enter the network name (ESSID) and channel.
  • Activate the settings and pass the popcorn

Lastly; the krauts:

SuSE Personal 9.2

Yea, I'll get back to this.