Saturday, October 13, 2012

Disable TouchPad on Dell E6510 in Ubuntu

The touch pad on my laptop is way too sensitive. When I am typing on the keyboard my palms frequently brush the corners and send the mouse pointer flying off into unexpected screen real estate. For that reason I use this little command, stored in a script, for easy shell execution when I have an external mouse.

xinput | grep TouchPad | sed s/id=// | awk '{system("xinput set-prop " $7 " \"Device Enabled\" 0")}'

So here's the novice explanation of what this does. (I'll assume you know that the pipe ( "|" ) sends the output of one command as input to the next.) The command xinput controls the various input devices. Running the command on its own displays a list of input devices and (crucially) their id. Since the id changes from time to time we can't hard code it. So we run xinput and pipe the results through grep to get just the line we want, which includes the word TouchPad. Any other unique string from that line item would have sufficed. The actual description is "AlpsPS/2 ALPS DualPoint TouchPad". So now we have this line, returned from xinput and filtered by grep:

⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad         id=13 [slave  pointer  (2)]

Lots of extra info there since all we want is the 13. awk is a useful script for pulling apart tokens in a line, but it first needs the 13 to be by itself. To do that we'll use sed (stream editor) and run this line through the regular expression s/id=//. That just replaces all instances of the string "id=" and replaces them with "". So now we have:

⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad         13 [slave  pointer  (2)]

Great! Time to craft our xinput command to actually disable the touchpad. The actual command we want is as follows:

xinput set-prop 13 "Device Enabled" 0

We use awk to run that as a system command, passing our altered line from sed to it and sticking token 7 in between set-prop and "Device Enabled". There. Stick it into a .sh file and chmod u+x and you're done! Oh, and to turn it back on, use a 1 instead of a 0.

1 comment:

  1. I know some of these words... Eg. "awk" is a sea bird that eats fish. And "grep" is a potty word from Battlestar Galactica.

    Touchpads are a real mixed blessing. Their default location on laptops is GUARANTEED to cause problems as you type... but where else are you going to put them? Above the keyboard, and you lose those nice wrist rest areas that make laptop typing not a total ergonomic nightmare. At the side, and your keyboard has to be narrower (also you will have to pick a handedness). Luckily my home laptop has a button that just... turns off the touch pad. So simple!


I had to add anti-spam measures because, let's face it, almost nobody comments on blogs anymore unless they are spamming. Sorry.