I just discovered that I couldn't add more than 4 layouts for my keyboard. Googling revealed that it was a universal limit (at least for GNU/Linux) and the only way(s) to get around it was to use some hackish way with scripts. Is there really a technical reason behind this? If yes, what is it?
Quoting Peter Hutterer (Red Hat employee working on X.Org):
Some information about this feature and why it hasn't been implemented yet: Te 4 group limit is forced by the protocol wire format. support for more than 4 groups can only be added by adding additional requests and events to XKB and rewriting clients to switch to this new XKB version. In addition, compatibility to the old protocol must be ensured so that current XKB clients will still function correctly with the new XKB version.
This is both complex and very time-consuming. Volunteers to tackle this problem are of course very welcome.
It's encoded in some bits on the protocol, with the other bits being used for other information. so you need extra bytes in the requests/events for anything above 4, and adding extra bytes requires bumping the protocol. And then you have to deal with those clients that only understand 4 groups and what to do with them if a keyboard is on group 5.
Why we don't have a hack above this layer - I don't know... this must be the lamest limitation ever. :D
I frequently write in English, German, Swedish and Chinese. This is four, but I am learning Russian as well and would appreciate the extra toggle via the GUI. Scripts is a workable resolution in the meantime:
One might note that with Russian, one has the option of either the 'standard' Russian keyboard layout, or a much more convenient (for those of us learning) phonetic layout paired to QWERTY.
Also, many of us use some form of Dvorak, which also takes a position.
Hence, my computer looks like this:
USA Dvorak (programmer) Swedish German Russian Russian phonetic
and there is an additional keyboard icon with an ibus toggle for Chinese Pinyin.
The protocol sets aside two bits for keyboard switching. This is two more than many people need. Most of the users I have seen switching keyboard layouts use two; a local layout and and international layout. The international layout usually handles composition of all require keys. This leaves one excess bit. I have seen users with three layouts, but usually one is never used.
I would be interested in what you are doing that requires more than four layouts, and how you work with constantly changing keymapping. I find it difficult to get users used to two layouts, even when it solved problems they have with internationalization.