4

My laptop's keyboard isn't working anymore. Therefore, I wrote a script which would disable the on-board keyboard with xinput float ID. On the new version of Ubuntu (17.10) this isn't working anymore due to the update to wayland.

When I Iist my devices with sudo libinput list-devices, I get:

[...]
Device:           Rapoo E6100
Kernel:           /dev/input/event13
Group:            6
Seat:             seat0, default
Capabilities:     keyboard
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   n/a
Rotation:         n/a
[...]
Device:           AT Translated Set 2 keyboard
Kernel:           /dev/input/event4
Group:            9
Seat:             seat0, default
Capabilities:     keyboard
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      n/a
Nat.scrolling:    n/a
Middle emulation: n/a
Calibration:      n/a
Scroll methods:   none
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   n/a
Rotation:         n/a
[...]

Rapoo E6100 is the working keyboard and AT Translated Set 2 keyboard is the broken, on-board keyboard.

I read that in order to have a device ignored, the capabilities can be removed from it (https://wayland.freedesktop.org/libinput/doc/latest/udev_config.html#udev_device_type). How can this be achieved with libinput?

Or is there a possibility to simply ignore the group 9?

1 Answers1

0

A quick and dirty way to disable the keyboard may be to use evtest to grab it. Then events are delivered to the test program, and no longer pass through to the graphics server.

$ sudo evtest --grab /dev/input/event4 >/dev/null

You must leave this program running all the time.


A more difficult way to disable the device is by adding a udev rule for it that sets ID_INPUT to empty, so that libinput will ignore it. I have not tried the following, so use it as a guide to explore rather than a definitive solution.

First, list the udev info for the event device that is the keyboard, eg:

$ udevadm info /dev/input/event4
...
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_INPUT_KEYBOARD=1
E: ID_SERIAL=05f3_0007

You now have to find something that will uniquely identify your device. Typically this is a usb vendor and product id (as in the ID_SERIAL above). The E: prefix means this variable is set in the udev environment, so in a udev rule you should say you want to match ENV{ID_SERIAL}=="05f3_0007".

However, for your laptop you will probably need to find something else to match on. You can search higher up the tree of devices to find a parent with an attribute that is easier to match for:

$ udevadm info -a /dev/input/event4
...
looking at parent device '/devices/pci0000:00/.../input/input4':
  KERNELS=="input4"
  SUBSYSTEMS=="input"
  ATTRS{name}=="HID 05f3:0007"
  ...

So, instead a udev rule matching on ID_SERIAL, you could match on ATTRS{name}=="HID 05f3:0007" instead. In your case I would expect something like ATTRS{name}=="AT Translated Set 2 keyboard".

Once you have found a suitable match, create your own file /etc/udev/rules.d/99-my.rules (start with 99 to make your rule last) with your overriding rule to reset the ID_INPUT value to empty. Be strict with the format of this file. Note how all the conditions are comparisons with == except the last which is an assignment with a single =.

ACTION=="add|change", ENV{ID_SERIAL}=="05f3_0007", ENV{ID_INPUT}=""

or more probably for you:

ACTION=="add|change", ATTRS{name}=="AT Translated Set 2 keyboard", ENV{ID_INPUT}=""

Normally the change to a file should be noticed automatically by udev, but if not do sudo udevadm control --reload. You can then try to trigger a change of the device:

$ sudo udevadm trigger --action=change /dev/input/event4

I'm not sure how this works for a fixed device, as usually for usb devices you can simply unplug it and plug it in again, so you may need to reboot.

You can monitor what udev is doing with udevadm monitor.

meuh
  • 3,444