21
Technology & Information / Custom keyboard layouts in X11
« on: April 03, 2021, 12:53:52 AM »
As a student of the Irish language, I wanted a way to enter a sineadh fada without using the XCompose method that has served me so well up to this point. The reasons are efficiency and accuracy: XCompose requires three keystrokes to input é, as opposed to two for a keyboard layout with AltGr+e; and this has the knock-on effect of making mistakes commonplace, such as pressing the keys in the wrong order and getting *iománáiocht instead of iománaíocht.
Unfortunately, the standard Irish keyboard layout is based on the terminally crippled UK layout, which means that it has (among other things) @, ", #, ~ and a few other symbols in the wrong places. Therefore, I took it upon myself to learn how to write my own xkb symbols file to create an ANSI-based Irish keyboard layout.
This turned out to be quite straightforward. The main annoyance is that if you make a mistake, X gives you no information whatsoever except that your symbols file has a mistake somewhere in it. But with a little trial and error, it's easy to get something that works well.
And so, behold! My new keyboard layout. I simply inherited the us(basic) layout I was already using (I don't want any of my existing usage to change), and added some new characters as combinations with AltGr. Each key has four symbols associated with it, corresponding to the key on its own, with Shift, with AltGr and with AltGr+Shift, respectively. NoSymbol means not to change the existing behaviour, which is why I used it everywhere that AltGr is not involved.
Unfortunately, the standard Irish keyboard layout is based on the terminally crippled UK layout, which means that it has (among other things) @, ", #, ~ and a few other symbols in the wrong places. Therefore, I took it upon myself to learn how to write my own xkb symbols file to create an ANSI-based Irish keyboard layout.
This turned out to be quite straightforward. The main annoyance is that if you make a mistake, X gives you no information whatsoever except that your symbols file has a mistake somewhere in it. But with a little trial and error, it's easy to get something that works well.
And so, behold! My new keyboard layout. I simply inherited the us(basic) layout I was already using (I don't want any of my existing usage to change), and added some new characters as combinations with AltGr. Each key has four symbols associated with it, corresponding to the key on its own, with Shift, with AltGr and with AltGr+Shift, respectively. NoSymbol means not to change the existing behaviour, which is why I used it everywhere that AltGr is not involved.
Code: [Select]
xkb_symbols "basic" {
include "us(basic)"
name[Group1]= "Irish (ANSI)";
// Euro on 5 key
key <AE05> { [ NoSymbol, NoSymbol, EuroSign, cent ] };
// Q row
key <AD03> { [ NoSymbol, NoSymbol, eacute, Eacute ] };
key <AD04> { [ NoSymbol, NoSymbol, 0x100027C, NoSymbol ] };
// long r
key <AD05> { [ NoSymbol, NoSymbol, tabovedot, Tabovedot ] };
key <AD07> { [ NoSymbol, NoSymbol, uacute, Uacute ] };
key <AD08> { [ NoSymbol, NoSymbol, iacute, Iacute ] };
key <AD09> { [ NoSymbol, NoSymbol, oacute, Oacute ] };
key <AD10> { [ NoSymbol, NoSymbol, pabovedot, Pabovedot ] };
// A row
key <AC01> { [ NoSymbol, NoSymbol, aacute, Aacute ] };
key <AC02> { [ NoSymbol, NoSymbol, sabovedot, Sabovedot ] };
key <AC03> { [ NoSymbol, NoSymbol, dabovedot, Dabovedot ] };
key <AC04> { [ NoSymbol, NoSymbol, fabovedot, Fabovedot ] };
key <AC05> { [ NoSymbol, NoSymbol, gabovedot, Gabovedot ] };
// Z row
key <AB01> { [ NoSymbol, NoSymbol, 0x100017F, 0x1001E9B ] };
// long s, long s dot
key <AB03> { [ NoSymbol, NoSymbol, cabovedot, Cabovedot ] };
key <AB05> { [ NoSymbol, NoSymbol, babovedot, Babovedot ] };
key <AB07> { [ NoSymbol, NoSymbol, mabovedot, Mabovedot ] };
include "level3(ralt_switch)"
};