how to bind AltGr to <Ctrl> + <Alt>
You need to define a new xkb type. You can see examples in your xkb/types directory (usually /usr/share/X11/xkb/types
). There you can define arbitrary combinations of modifiers to get different levels of shifting. For your problem, you can use something like this:
type "C_A_to_L3" {
modifiers = Control+Alt+Shift;
map[None] = Level1;
map[Shift] = Level2;
map[Control+Alt] = Level3;
map[Control+Alt+Shift] = Level4;
level_name[Level1] = "Base";
level_name[Level2] = "Shift";
level_name[Level3] = "Alt Base";
level_name[Level4] = "Shift Alt";
};
Then in your symbols file you can set that type as the default, or set on a per-key basis what type it is. Note that you need the type to be in a file in the types directory, and the key definition in a file in the symbols directory -- xkb uses a strict filesystem hierarchy to find each component.
I've done a fair bit of hacking on keyboard layouts myself to build my custom layout (https://github.com/willghatch/hatchak), which has gone through various iterations where I've experimented with weird things. XKB can be pretty finnicky and strange at times, but it is still the most configurable keyboard system I've seen by far. The best references if you have more troubles are:
[edit: original links are currently down, but thankfully archive.org exists]
https://web.archive.org/web/20150722164820/http://www.charvolant.org/~doug/xkb/html/index.html
and
https://web.archive.org/web/20190419170426/http://pascal.tsu.ru/en/xkb/
Beware -- while that's the best documentation I've found, it leaves plenty of murky edge cases. Good luck.
Related videos on Youtube
user2769706
Updated on September 18, 2022Comments
-
user2769706 over 1 year
I am trying to create a linux equivalent of Ergonomic Telugu Keyboard layout called Sarala (Hard la). I have been able to map all the keys so far. The layout uses the following key combinations for various levels.
None (Base): Level1 Shift: Level2 Ctrl + Alt: Level3 Ctrl + Alt + Shift:Level4
Where as linux uses the following for various levels.
None (Base): Level1 Shift: Level2 RAlt: Level3 RAlt + Shift:Level4
To be able to match the key combinations with my layout, I would have to map AltGr with a Ctrl + Alt. I have unsuccessfully searched though various files in
/usr/share/X11/xkb/
. Does any body know how I can bind theISO_Level3_Shift
with Ctrl + Alt ?key <RALT> { symbols[Group1]= [ Mode_switch, Multi_key ], virtualMods= AltGr };
If you want to look at the layout, it's here
-
αғsнιη over 9 yearshave a look here askubuntu.com/questions/254424/…
-
user2769706 over 9 yearsThankyou, that is very informative but it talks about everything else except
xkb
configuration. -
No Time over 9 yearsYou can look through this wiki from arch linux wiki, and check out the part about Alt and Altgr (Level 3). I am not sure if this will help you, but it seems to have a lot of information about XKB
-
user2769706 over 9 yearsI have tried that, xkb fails to load with a not so descriptive error. I don't have the error handy, but I can attach it later.
-
-
user2769706 over 9 yearsI am not asking for personal use, I need to ship the layout. Unfortunately this is a bad answer. Thankyou however.
-
Dave almost 8 yearsI think your idea is really useful, but I'm really struggling to use the created type in the symbol files as default as you mentioned. The symbol files I have on my computer are quite long and I don't see any line that looks like a definition of a default type.
-
William Hatch almost 8 yearsYou can define a default for a section within a symbols file by setting
key.type
. You can probably see an example at/usr/share/X11/xkb/symbols/srvr_ctrl
(or somewhere like that), in the "no_srvr_keys" section. Here is what I have: xkb_symbols "no_srvr_keys" { key.type="TWO_LEVEL"; key <FK01> { [ F1, F1 ] }; key <FK02> { [ F2, F2 ] }; <etc...> }; -
Dave almost 8 yearsThanks for the quick answer. I think I will be able to apply that. Thanks a lot in advance.
-
Dave over 7 yearsJust as a feedback for all those coming to this page back even a long time later. For me this approach worked now with a newly installed Fedora. For some (to me) unknown reason it did not work with Mint when I wrote that comment above. But now it works and saves me a lot of time.