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"
Answer
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
Comments
Post a Comment