Linux: How to Set Different Layouts for 2 Keyboards

By Xah Lee. Date: .

Here's, how to set different layouts for 2 physical keyboards.

  1. First, use xinput to identify your keyboards.
  2. Then, use setxkbmap to set the layout.

Example:

# Use xinput to find your keyboards.

$ xinput
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=11   [slave  pointer  (2)]
⎜   ↳ TPPS/2 IBM TrackPoint                     id=12   [slave  pointer  (2)]
⎜   ↳ Logitech Performance MX                   id=14   [slave  pointer  (2)]
⎜   ↳ E-Signal USB Gaming Keyboard              id=16   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ Integrated Camera                         id=9    [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=10   [slave  keyboard (3)]
    ↳ ThinkPad Extra Buttons                    id=13   [slave  keyboard (3)]
    ↳ Sennheiser Sennheiser 3D G4ME1            id=15   [slave  keyboard (3)]
    ↳ E-Signal USB Gaming Keyboard              id=17   [slave  keyboard (3)]

# My keyboards are id 10 (laptop integrated) and id 17 (external keyboard).

# Now, set my external keyboard to be Swedish layout, and my internal to Dvorak:
$ setxkbmap -device 17 se
$ setxkbmap -device 10 dvorak

2018-02-13, thanks to Henrik Sjöstrand, https://gist.github.com/hencjo/0710d51c5ba51e0aeb2d905f1e3a38f3

Linux Keybinding How-to

  1. Keyboard Software Guide
  2. Swap Control Alt Keys
  3. Set F2 F3 F4 to Cut Copy Paste
  4. CapsLock → Escape
  5. CapsLock → Home
  6. Shift Lock
  7. Key to Switch App
  8. Key Repeat Rate
  9. System Keyboard Layout
  10. Switch Keyboard Layout
  11. Change Volume
  12. xmodmap
  13. xbindkeys
  14. xvkbd
  15. Find Keyboard Key Scancode
  16. X11 Keyboard Key Names
  17. 2 Layouts for 2 Keyboards
  18. Chinese Input Setup

Mouse

  1. Mouse Hover to Auto-Raise Window
  2. Mouse Hover-Click
  3. Set Mouse Single-Click to Open File
  4. How to Set Mouse Speed
  5. How to Swap Mouse Buttons
  6. Set Trackball/Mouse Do Scroll
  7. Setup Accelerated Scroll and AutoScroll
  8. X11 Mouse Button Numbering

If you have a question, put $5 at patreon and message me.