5

I want to disable a keyboard input device with libinput. Something analogous to:

xinput set-int-prop 1 "Device Enabled" 8 0

which follows the syntax:

--set-int-prop device property format value

Sets an integer property for the device. Appropriate values for format are 8, 16, or 32, depending on the property. Deprecated, use --set-prop instead.

(or like xinput set-prop).

I want to use this to disable a keyboard-emulating authentication dongle (Yubikey) from "typing out" out a token from a spurious touch.

Perhaps there is a preferred method not involving libinput to do this. I do not want to disable the dongle completely, as it has features other than generating a token through its keyboard emulation (it is a GPG smart card too).

I am using Fedora 26 with Wayland.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Justin
  • 51

2 Answers2

2

fwiw, the LIBINPUT_IGNORE_DEVICE udev property can be assigned to devices that should be ignored. Detailed docs are here:

https://wayland.freedesktop.org/libinput/doc/latest/device-configuration-via-udev.html#ignoring-devices

whot
  • 626
  • If the device is both keyboard and mouse, I wonder, if you can disable only one of them temporarily, if desired? – jarno Jul 24 '20 at 09:21
  • 1
    Depends. The udev property works per kernel device, so per event node. Some physical devices expose multiple event nodes for different capabilities - that's quite common. Since they're different event nodes, you can disable them. Rarer are those that expose one event node with multiple capabilities and you cannot disable parts of those (they are only libinput device, the xf86-input-libinput driver may split them into multiple X devices though but that's not needed under Wayland). – whot Jul 25 '20 at 10:45
1

I don't know any method involving libinput, but you can do an exclusive grab on the /dev/input/event* device that corresponds to the Yubikey. This works on the kernel input layer, with an ioctl, and prevents any other application (e.g. Wayland using libinput) from processing events from this device.

Normally whatever program that intends to use features on the Yubikey should do the grab, but you can test it out with evtest --grab and choosing the Yubikey, or evtest --grab /dev/input/eventX if you know the device or a symlink to it.

The ioctl is EVIOCGRAB, defined in /usr/include/linux/input.h, in case you want to use it from a program. Also works with Python and other scripting languages that can do iotctls.

dirkt
  • 32,309