You are not logged in.

#1 2021-05-13 09:24:24

saiko
Member
Registered: 2021-05-12
Posts: 10

Custom keyboard layouts

I've been trying to wrap my head around keyboard layouts in X11, specifically, modifying and creating them.

I want to create a layout that has all the letters of my language, but I want to avoid using AltGr to access them. My idea is to use "dead key", but as far as I know, it work only for a set number of diacritics. So, it works like this: I press a dead key with ¨ symbol, it waits until I press another key that this symbol can be applied to, O for example, and it produces ö. But I want it to work something like this: for example, I press P key, it waits until press another key, for example, L, and it produced D letter. Those letter are just for example.

I think it can be done in Windows layouts, but is it possible in X11?

Offline

#2 2021-05-13 10:40:17

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

https://wiki.archlinux.org/title/Xorg/K … ompose_key
CapsLock is particularily useless and lends itself to that role.
A lot of combinations are already pre-defined in /usr/share/X11/locale/en_US.UTF-8/Compose which you (msot likely) want to include in your local definition.

Edit: there're also more elaborate input methods, see https://wiki.archlinux.org/title/Fcitx

Last edited by seth (2021-05-13 10:41:00)

Offline

#3 2021-05-13 11:36:02

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

https://wiki.archlinux.org/title/Xorg/K … ompose_key
CapsLock is particularily useless and lends itself to that role.
A lot of combinations are already pre-defined in /usr/share/X11/locale/en_US.UTF-8/Compose which you (msot likely) want to include in your local definition.

Edit: there're also more elaborate input methods, see https://wiki.archlinux.org/title/Fcitx


Do I understand correctly that this would require setting up Compose key by user and other actions? My goal is to create a layout that just works "out of the box", as any other.

Offline

#4 2021-05-13 11:48:49

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

Check /usr/include/X11/keysymdef.h
You can use

/* dead vowels for universal syllable entry */
#define XK_dead_a                        0xfe80
#define XK_dead_A                        0xfe81
#define XK_dead_e                        0xfe82
#define XK_dead_E                        0xfe83
#define XK_dead_i                        0xfe84
#define XK_dead_I                        0xfe85
#define XK_dead_o                        0xfe86
#define XK_dead_O                        0xfe87
#define XK_dead_u                        0xfe88
#define XK_dead_U                        0xfe89

but there's nothing like "dead_p" and even ifff: deadkey input in the existing layout relies on the compose feature.

You can provide a compose locale that has eg.

<dead_a> <b>                    : "?"

and a symbol table (look up /usr/share/X11/xkb/symbols/*) that maps key <AC01> to dead_a, dead_A

Edit: and maybe be more specific about "language" and what input you actually envision.
The amount of languages is rather limited, so chances are somebody actually has solved your problem in the past…

Last edited by seth (2021-05-13 11:50:50)

Offline

#5 2021-05-13 12:29:58

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

Check /usr/include/X11/keysymdef.h
You can use

/* dead vowels for universal syllable entry */
#define XK_dead_a                        0xfe80
#define XK_dead_A                        0xfe81
#define XK_dead_e                        0xfe82
#define XK_dead_E                        0xfe83
#define XK_dead_i                        0xfe84
#define XK_dead_I                        0xfe85
#define XK_dead_o                        0xfe86
#define XK_dead_O                        0xfe87
#define XK_dead_u                        0xfe88
#define XK_dead_U                        0xfe89

but there's nothing like "dead_p" and even ifff: deadkey input in the existing layout relies on the compose feature.

You can provide a compose locale that has eg.

<dead_a> <b>                    : "?"

and a symbol table (look up /usr/share/X11/xkb/symbols/*) that maps key <AC01> to dead_a, dead_A

Edit: and maybe be more specific about "language" and what input you actually envision.
The amount of languages is rather limited, so chances are somebody actually has solved your problem in the past…

My language is Russian, and it just has too many letters to fit on a keyboard designed for English language. Even in modern reduced state. For example. the letter Ё is placed where ` or ~ is on English layout, and it is part of the reason people tend just not to use it - you gotta stretch your pinkie or ring finger to reach it.

Offline

#6 2021-05-13 12:34:47

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

As for what I envision, it is something like this.

On ] button there is Ъ letter in Russian layout, which is actually rarely used. I would like to make it a sort of combo key. For starters, if you press it twice (or follow with space or another key that does not result in "combo"), it types Ъ as usual. But if you press it and follow by pressing Russian О, it results in Ё (it makes sense, because it is pronounced "yo"). That's the baseline of what I want to achieve. There is a number of other letters that I would like to use this method for which are not present on modern keyboards or layouts.

Offline

#7 2021-05-13 13:14:38

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

You'd eg. assign "key <AD12>" to "dead_i" in your layout and map <dead_i> <dead_i> : "Ъ", <dead_i> <О> : "Ё", … in the compose map.
You *need* to use *some* dead key to trigger the composition and have the latin vowels (aside the diacritics) at your disposal (next to the multi_key)

Cyrillic_io and Cyrillic_hardsign (dude, you have a weird language ;-) in particular are mapped to other keys notably on the typewriter, ossetian and ukrainian layout variants.
You can invoke the composition map through the locale, but that will also require the users to select the ru_Saiko.utf-8 locale.

Offline

#8 2021-05-13 22:15:43

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

You'd eg. assign "key <AD12>" to "dead_i" in your layout and map <dead_i> <dead_i> : "Ъ", <dead_i> <О> : "Ё", … in the compose map.
You *need* to use *some* dead key to trigger the composition and have the latin vowels (aside the diacritics) at your disposal (next to the multi_key)

Cyrillic_io and Cyrillic_hardsign (dude, you have a weird language ;-) in particular are mapped to other keys notably on the typewriter, ossetian and ukrainian layout variants.
You can invoke the composition map through the locale, but that will also require the users to select the ru_Saiko.utf-8 locale.


OK, this is onto something. Basically, I will have to create my own custom locale?

Offline

#9 2021-05-14 07:26:16

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

You'll hac to create your own keyboard layout and xcompose map.
The locale will just allow users to use that xcompose map by default - they could also copy it to ~/.XCompose

Offline

#10 2021-05-14 09:46:58

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

Thank you for the suggestion, I will try this as soon as I have time to tinker around.

Could you point me to documentation where it is all described? I tried to look something up, but it seemed like bits and piece of info, and not a coherent manual.

Offline

#11 2021-05-14 13:21:44

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

You'd eg. assign "key <AD12>" to "dead_i" in your layout and map <dead_i> <dead_i> : "Ъ", <dead_i> <О> : "Ё", … in the compose map.
You *need* to use *some* dead key to trigger the composition and have the latin vowels (aside the diacritics) at your disposal (next to the multi_key)

Cyrillic_io and Cyrillic_hardsign (dude, you have a weird language ;-) in particular are mapped to other keys notably on the typewriter, ossetian and ukrainian layout variants.
You can invoke the composition map through the locale, but that will also require the users to select the ru_Saiko.utf-8 locale.


Is "dead_i" an arbitrary example or there is a list of specific definitions that can be assigned as "dead"? Can I assign "dead_ъ", for example?

Offline

#12 2021-05-14 16:08:05

seth
Member
Registered: 2012-09-03
Posts: 58,717

Offline

#13 2021-05-14 21:14:04

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

https://bbs.archlinux.org/viewtopic.php … 2#p1972652

Can I assign "dead_ъ", for example?

Nope.

But what is it limited to? Latin letters?

Offline

#14 2021-05-15 07:22:30

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

seth couple of times wrote:

Check /usr/include/X11/keysymdef.h
You can use

/* dead vowels for universal syllable entry */
#define XK_dead_a                        0xfe80
#define XK_dead_A                        0xfe81
#define XK_dead_e                        0xfe82
#define XK_dead_E                        0xfe83
#define XK_dead_i                        0xfe84
#define XK_dead_I                        0xfe85
#define XK_dead_o                        0xfe86
#define XK_dead_O                        0xfe87
#define XK_dead_u                        0xfe88
#define XK_dead_U                        0xfe89

but there's nothing like "dead_p"

seth also wrote:

have the latin vowels (aside the diacritics) at your disposal (next to the multi_key)

Offline

#15 2021-05-15 09:09:25

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

Oh, yes, sorry, I should pay more attention.

I wonder, is it possible to add user-defined keysyms?

Offline

#16 2021-05-15 09:18:57

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

You probably don't mean "by patching xkb and xim"?
Why do you think that would be beneficial? Do you need more than 2x5 dead keys?
This has nothing to do with using latin vowels, you're just mapping the scancodes there and then lever those to some cyrillic input in the xcompose map.
They're effectively just variable names.

Offline

#17 2021-05-15 09:35:51

saiko
Member
Registered: 2021-05-12
Posts: 10

Re: Custom keyboard layouts

seth wrote:

You probably don't mean "by patching xkb and xim"?
Why do you think that would be beneficial? Do you need more than 2x5 dead keys?
This has nothing to do with using latin vowels, you're just mapping the scancodes there and then lever those to some cyrillic input in the xcompose map.
They're effectively just variable names.

I tried it quickly yesterday, and I think the problem was that <dead_i> still acted as, well, dead i, so when I pressed it and then followed it with some other key which was not defined in the compose map, it resulted in placing some weird little "i" letter next to A letter, for example.
Basically, I want the following: if I press that dead key and follow by a combo defined in compose map, it should result in a specified extra letter, but if I follow it by a key that is not defined as combo, it should result in ъ letter, not as a diacritic of "i" added to the following letter. Or if it just did nothing if follow by not-combo key press.
Hopefully this makes sense.

Offline

#18 2021-05-15 12:55:22

seth
Member
Registered: 2012-09-03
Posts: 58,717

Re: Custom keyboard layouts

weird little "i" letter next to A letter, for example

Can you please post the actual output, because that looks like some unicode error (Ã is the UTF-8 head in a non-utf8 environment)

What should™ happen is that if you input "dead_i anythingnotcomposed" you just get no output for the dead key, ie.

xdotool key dead_u i

prints just the "i"

You will have to specify every composition you want (so typically "<dead_u> <space>" and "<dead_u> <dead_u>" producing whatever output you wanted from the "plain" key.

Offline

Board footer

Powered by FluxBB