Belated, but I wanted to expound upon the answers up above just a bit for Apple users. I have a MBP with a busted internal keyboard, and I've been using evtest
to grab input from it and send it to /dev/null
. This seems to be the most common suggestion floating around. The problem with this solution is that the event number changes if the kernel is updated, and if you have a script that runs at boot like I do, this number has to be manually updated with each kernel update. This is where using unbind
comes in, and how the answer above inspired me to finally ditch evtest
. I've come up with a simple one-liner, and it seems to do the job perfectly.
Here's the full command:
head /sys/bus/hid/drivers/*/*/*/*/name | grep "apple" | sed -E 's/[^0-9A-F:.]*//g' | awk '{ print substr( $0, 1, length($0)-2 ) }' > /sys/bus/hid/drivers/apple/unbind
We know what the first part of this does, so I'll explain the need for sed
and awk
. Running just head
along with a grep
will output something akin to this:
/sys/bus/hid/drivers/apple/0003:046D:C077.0003/input/input18/name
Now, we use sed
to get rid of everything that's not a hexadecimal character:
0003:046D:C077.000318
You'll notice that the input number is also included on the end there, which we don't need, so we use awk
to remove the last two characters of the string:
0003:046D:C077.0003
And of course, we have the output direction sending this string to /sys/bus/hid/drivers/apple/unbind
. Plop this into a script that you can run at boot, and tada! The caveat to this is that it'll have to be modified for hid-generic
devices. Apple has its own input driver directory that makes this a bit simpler, and grep
'ing for just "apple" suffices.
Edit: This is the beauty of crowd-sourced information. Thanks go to Stephen Kitt down below for this solution. It's much more elegant than mine, and properly takes input device numbers into consideration.
for name in /sys/bus/hid/drivers/apple/*/*/*/name; do device=$(cut -d/ -f7 <<<"$name"); [ "$device" != "*" ] && printf "%s" "$device" > /sys/bus/hid/drivers/apple/unbind; done