Adding a custom keyboard layout (and setting it as the default)

keyboard-layoutxkb

I'm on Arch Linux with i3, and I'm trying to create a personalized layout with IPA (International Phonetic Alphabet) symbols for use in linguistic research. I'm also using iBus for Chinese language input, and of course want to keep that, too.

The method I want to use for input is AltGr+{key} to give me IPA symbols, and use that together with a standard US English keyboard. Apparently this means using XKB. Xmodmap is described as too simple and deprecated (and I'm not even sure it supports Unicode completely), and Compose Key
is too cumbersome of a way to type efficiently.

I've been through the Arch wiki article on XKB and the links at the bottom of said article, as well as doing some digging on my own. I've taken a chunk of the /usr/share/X11/xkb/symbols/us file, copied it into a new file, edited and renamed it. I then edited the /usr/share/X11/xkb/rules/evdev.xml file to include my layout. But when I use the command setxkbmap iw (iw being the name of my layout), it gives me the following error:

Error loading new keyboard description

A lot of the documentation on this appears to be outdated, and I couldn't find clear instructions on how to actually install a layout after creating it. Forum posts and articles addressing similar issues (like this one or this guide) rely on GUI tools to finish the setup, which I don't have in i3 (admittedly I've just used i3 for two days, I'm clueless).

I don't think this has to do with the GUI tools though, as my system doesn't even recognize the layout. My guess is that I probably messed something up in the layout itself that makes it unrecognizable, or else failed to modify a certain config file to make the system see it. Does anyone know what I might have missed?

I figure if I can make the system recognize the layout, I can add it through iBus, as soon as I figure out how to make iBus start up automatically on login in i3…

Best Answer

Add an entry for the layout to /usr/share/X11/xkb/rules/xorg.lst under ! variant and add the layout to /usr/share/X11/xkb/symbols/us. Then it will be a variant of the us layout. Format of the entry to xorg.lst should be obvious from other entries. If you want the layout listed as a separate language, put the entry in xorg.lst under ! layout and the layout to a separate file name of which is the name of the layout.

Related Question