1

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"

2

2 Answers 2

1

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).

#!/bin/bash

# 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 
    quit_jobs
    # 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
        quit_jobs
        disable_pointer_temporarily &
    fi
done
1
  • 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
    Commented Jan 27, 2020 at 16:18
1

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:

#!/bin/bash
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

#!/bin/bash
killall pause-mouse
pause-mouse

Nicer solutions would be preferred!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .