Ubuntu – How to disable touchpad while using trackpoint on a Thinkpad


Thinkpads (e.g. X230 that I'm using) have both a trackpoint and a touchpad. The touchpad is disabled when typing.

However, when I'm using the trackpoint, I often touch the touchpad as well, and generate mouse clicks I'd like to avoid. Does anyone have an idea how disable mouse-clicks on touchpad when trackpoint is in use?

EDIT: also, can someone explain how the option of disabling touchpad when typing works? What is being done behind the scenes? Is it an xinput configuration command, and if yes, which one?

EDIT2: clarification; manually disabling Touchpad (even with a shortcut) is not the issue here. This should work just like the option "disable touchpad when typing", since I use Touchpad and Trackpoint interchangeably (most frequently, I use Touchpad for scrolling and Trackpoint for moving the cursor).

Best Answer

Disabling touchpad when keyboard is in use

This function is performed by the syndaemon utility, from the xserver-xorg-input-synaptics package. You can set options such as the idle time, the polling frequency, etc (see runtime help):

Usage: syndaemon [-i idle-time] [-m poll-delay] [-d] [-t] [-k]
  -i How many seconds to wait after the last key press before
     enabling the touchpad. (default is 2.0s)
  -m How many milli-seconds to wait until next poll.
     (default is 200ms)
  -t Only disable tapping and scrolling, not mouse movements.

Here's the source code for syndaemon.c.

  • The important functions are keyboard_activity(...) and main_loop(...)
  • keyboard_activity uses the XQueryKeyMap API call to get the current state of the keyboard (1 bit per key), and then compares is to the last (old) state; if they are different, it returns 1
  • main_loop polls keyboard_activity every m milliseconds, and based on the "last activity time" and whether keyboard_activity returns true or false, it decides whether to disable or enable the touchpad.
  • The dp_get_device function illustrates how X input devices are enumerated; you should be able to modify this and the keyboard_activity function to also check for any trackpoint activity.

  • The xinput tool lists devices and IDs, for example"

    Virtual core pointer                     id=2    [master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    ⎜   ↳ SynPS/2 Synaptics TouchPad                id=11   [slave  pointer  (2)]
    ⎜   ↳ TPPS/2 IBM TrackPoint                     id=12   [slave  pointer  (2)]

  • You can get this (the ID) via the XListInputDevices function

  • After that, you must get a device handle from the ID using the XOpenDevice
  • Then, you use the XQueryDeviceState function to obtain the coordinates of the TrackPoint pointer; similar to the existing loop, you poll this every so often and check if the coordinates have changed (i.e. the TrackPoint is in use), and use that to toggle the touchpad on or off
  • You can use the xinput utility with the query-state switch and device ID to check if your programming is correct, for example:

    $ xinput query-state 12
    2 classes :
    ValuatorClass Mode=Relative Proximity=In
  • You are interested in the valuator values, which are X and Y coordinates of the TrackPoint
  • See the xinput source for more tips
  • To modify and rebuild this package:

    1. Get the source with apt-get source...
    2. Make your modifications to tools/syndaemon.c
    3. Disable the existing syndaemon patches by commenting out the 118... and 124... lines in debian/patches/series
    4. Build your modified package with dpkg-buildpackage -us -uc and the deb files will be in the parent directory.