I've given up trying to get my touchpad registered correctly. It wants to be an imps/2 device, and I can't spend any more afternoons trying to convince it otherwise (in fairness, it does quite well as an imps/2 device - tap to click, 3-finger tap to middle-click, no horizontal scroll but you can't have it all)

However, I cannot live with the fact that the lightest brush causes the tap to fire.

Is there a command I can use to disable the touchpad when a key has been recently pressed? xinput seems to be my friend here, device appears and can be configured as "ImPS/2 Generic Wheel Mouse"


I improved your solution so that there is no need for several files, there is less to grep and minor robustness improvements. In the code I use 'Logitech K400' device that I use, but you can change it. (With that device I want to disable mouse when Ctrl is down, but it is a different story and code.) I don't know how well it works for you that you disable the mouse only after key release. It might be better for you to start the disable on key press, except when it is a modifier key such as Ctrl, and enable after some delay after key release (ignoring modifier keys again).


# Use 
# $ xinput --list
# to get the device names and test them with 
# $ xinput --list "name"

# Modify the pointer device name to match your hardware
pointer_id=$(xinput list --id-only 'pointer:Logitech K400')
# Modify the keyboard name to match your hardware
keyb_id=$(xinput list --id-only 'keyboard:Logitech K400')

# exit, if the devices are not available
[[ $pointer_id && $keyb_id ]] || exit 1

quit_jobs() {
    # terminate all running jobs, if any
    kill $(jobs -pr) 2>/dev/null || :

# Prepare the script for exit
revert() {
    # Terminate `xinput test` and other possible processes 
    # The pointer may be disabled
    xinput enable $pointer_id
trap revert EXIT

disable_pointer_temporarily() {
    xinput disable $pointer_id
    sleep 0.5
    xinput enable $pointer_id

xinput test $keyb_id | while read -r line; do
    if [[ $line == key\ release* ]]; then
        disable_pointer_temporarily &
  • 1
    That's a much nicer way to do it! Unfortunately the laptop became increasingly unusable, and now lies abandoned, but if I ever get around to resurrecting it this is certainly the code I will use! Thanks! – user208769 Jan 27 '20 at 16:18

My very hackish solution so far:

xinput test-xi2 --root | grep --line-buffered RawKeyRelease | while read -r line ; do pause-mouse-with-kill & sleep 0 ; done

This reports on any input passed to xorg, checks whether it's a keypress release (so I can still ctrl-click things) and disables the mouse momentarily. That's where things get even more hackish - two files are needed to prevent repeated keypresses extending the mouse timeout:

/usr/bin/pause-mouse do the actual mouse disabling:

DEV="ImPS/2 Generic Wheel Mouse" ; xinput set-prop "$DEV" "Device Enabled" 0 && sleep 0.5 && xinput set-prop "$DEV" "Device Enabled" 1 

/usr/bin/pause-mouse-with-kill Cancel the previous mouse-disable, and restart the clock

killall pause-mouse

Nicer solutions would be preferred!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.