8

Ideally, I'm looking for a GUI tool, maybe a web application, but good documentation on creating a text definition for a keyboard layout would be great too. What is the normal procedure here?

In this question, the asker already decided on using "setxkbmap". Is this the recommended way? Can I add the layout to eg a git repo so I can make changes to it over time if I need to?

1 Answer 1

14

You can edit keymaps with XKeyCaps. On the upside, XKeyCaps is a GUI and it's very mature. A downside of XKeyCaps is that it's only a front-end to the old-style X window keymap interface, xmodmap, and not the modern interface, XKB.

It's perfectly fine to use xmodmap if you want, but it isn't as powerful as XKB. XKB features that xmodmap lack include:

  • A better handling of modifiers. X11 has many quirks related to modifiers, including the fact that CapsLock and NumLock are considered modifiers. An example of a thing that I do with XKB that doesn't work with xmodmap is that I make Alt+CapsLock be Lock (that's how X11 spells Caps Lock), but not CapsLock itself. Another thing xmodmap can't do is to have different sets of modifiers influence different keys, for example to have Shift and AltGr affect printable characters but Ctrl and Alt affect function keys.
  • XKB is made of composable modules. Xmodmap is monolithic. This is great for people who want to combine predefined settings (“give me a Hungarian keyboard with Ctrl and CapsLock swapped and Alt+Windows is Menu, and for the key codes of a Sun 5 keyboard”), but you wouldn't care since you're making your own layout.
  • If you hotplug a keyboard, the XKB system defaults get reapplied. It's also an XKB limitation since the system defaults are reapplied, not your user settings.
  • XKB has better support for non-alphabetic languages or multi-script input. I can't give details because this is not a topic that I know well.
  • There are tools to quickly switch between layouts (for example to have window-specific layouts) or to indicate the current keyboard layout that only work with XKB.
  • I'm not sure if Wayland supports xmodmap.

There are a few XKB GUI editors on the web, but all the ones I can find are projects that were quickly abandoned and aren't as easy to install as XKeyCaps. I can't find one with an Ubuntu package, for instance.

If you decide to write the keymap manually, the advantage of xmodmap is that it's very simple. You can read the man page, maybe look at an example, and you'll quickly understand everything except the subtlety of modifiers. If you can't figure out how to do it with xmodmap, it's probably impossible. The advantage of XKB, once again, is that it's more powerful. The downsides of XKB are that it's complex and poorly documented. Some suggested reading if you want to go this route:

Whichever way you choose, the keymap source is a text file or a collection of text files which works well with version control.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .