How to automatically disable the laptop’s built-in keyboard in X.org

keyboardx11xorg

Distro and X.org Version Information

I am using Ubuntu 12.10 with xserver-xorg/quantal 1:7.7+1ubuntu4.

Disabling Built-In Keyboard in X11

I have a laptop with a built-in keyboard that no longer recognizes certain letters. I am currently disabling the built-in keyboard by opening a terminal and running the following shell function:

disable_keyboard () {
  xinput --set-int-prop $(
    xinput --list |
    ruby -ane 'if /AT.*keyboard/ then puts $_.match(/(?<==)\d+/) end'
  ) "Device Enabled" 8 0
}

This works (albeit manually) by disabling the built-in AT Translated Set 2 keyboard while allowing my external Chicony USB Keyboard to continue working. However, I'd really like this to happen automatically during X11 sessions.

I tried modifying my X.org configuration as follows:

# /etc/X11/xorg.conf.d/disable_keyboard
Section "InputClass"
    Identifier      "disable built-in keyboard"
    MatchIsKeyboard "on"
    MatchProduct    "AT Translated Set 2 keyboard"
    Option          "Ignore"    "on"
EndSection

However, either this is not being sourced when X11 starts, or it is not the correct incantation. How can I correctly configure X11 to use only the USB keyboard?

Best Answer

Disable Built-In Keyboard and Trackpad with InputClass

One can disable the built-in devices by setting the Ignore option in an input class to true or on. The necessary information to match the devices can usually be gathered from /var/log/Xorg.0.log.

I chose to place my disabling sections in the evdev configuration file that was already present, since on my system both devices use the evdev driver. The sections could just as easily go somewhere else, but I'm unsure about the precedence of the matching rules and decided to play it safe by placing the rules in the same file above other devices that contain a Driver "evdev" line.

# /etc/X11/xorg.conf.d/10-evdev.conf

Section "InputClass"
        Identifier      "Built-In Touchpad"
        MatchIsTouchpad "on"
        MatchProduct    "SynPS/2 Synaptics TouchPad"
        Option          "Ignore" "true"
EndSection

Section "InputClass"
    Identifier          "Built-In Keyboard"
    MatchIsKeyboard     "on"
    MatchProduct        "AT Translated Set 2 keyboard"
    Option              "Ignore" "true"
EndSection
Related Question