Changing keyboard layout bindings  [Solved]

Message
Author
babythem
Posts: 20
Joined: Sun Oct 10, 2021 5:03 am

Changing keyboard layout bindings

#1 Post by babythem »

Using AVL MX-21 64-bit with Debian GNU/Linux 11 (bullseye) and Xfce 4.16.3.

I often have to switch between an English and Hindi keyboard for my day job, but I'm not happy with any of the existing keyboard layouts (Bolnagri, KaGaPa phonetic, and WX).* I was wondering where MX Linux stores keyboard layout files and if there's anyway to manually modify them and switch them around to create custom bindings? I've been searching for them but can't find anything --- e.g. running `sudo find / -iname *bolnagri*` doesn't give me any results anywhere on my file system.

Thanks!

*Referring to these two in particular, some of the bindings are awkward: https://i.stack.imgur.com/ZM5nI.png

thomasl

Re: Changing keyboard layout bindings  [Solved]

#2 Post by thomasl »

(Disclaimer: this works for MX19 and I suspect it'll work for MX21 as well but I can't test it.)

I was not happy with the GB (ie British) kbd layout and changed it significantly. Alas, the process is not entirely trivial and requires text editing system files. There may be utilities for that.

For a start you'll find the Indian kbd layouts in file /usr/share/X11/xkb/symbols/in (there may be other files with other definitions; I am not from India so can't say whether there's more).

Code: Select all

// This layout includes all Indian layouts, including:
//     - Devanagari (Hindi, Marathi, Sanskrit)
//     - Bangla
//     - Gujarati
//     - Kannada
//     - Malayalam
//     - Ol Chiki
//     - Oriya
//     - Tamil
//     - Telugu
//     - Urdu
You'll have to edit that file and change the definitions according to your preferences. It's not hard but tedious. :turtle:

babythem
Posts: 20
Joined: Sun Oct 10, 2021 5:03 am

Re: Changing keyboard layout bindings

#3 Post by babythem »

Lovely, thanks! Would've never figured out that all the various Indian layouts are hidden in that file...

Additional question: I see that for the Indian layouts, bindings are given by a key code (e.g. "<AD01>", "<AD02>") + unicode characters ("U0935", "U0947", etc.). E.g. here's an excerpt:

Code: Select all

//Q Row     
    key <AD01>   { [   U200C,   U200D   ] };  // Q: ZWNJ, ZWJ
    key <AD02>   { [   U0935,   U950    ] };  // W: wa, OM
    key <AD03>   { [   U0947,   U0948,  U090F,  U0910   ] };  // E: e, ai matras 
I'm wondering if there's any quick reference or diagram to tell which key code ("AD01", "AD02") refers to which key on the keyboard, assuming a generic PC keyboard layout? Or do I just have to count them and figure out myself? The author's comments in the above example help, but there aren't such comments for all the layouts...

Stuart_M
Posts: 709
Joined: Wed Aug 07, 2019 7:10 pm

Re: Changing keyboard layout bindings

#4 Post by Stuart_M »

babythem wrote: Sun Nov 06, 2022 3:17 pm ...
I'm wondering if there's any quick reference or diagram to tell which key code ("AD01", "AD02") refers to which key on the keyboard, assuming a generic PC keyboard layout?
...
Those are not key codes, they are scan codes (https://tldp.org/HOWTO/Keyboard-and-Con ... WTO-2.html).

To see what your scan codes are, look in /usr/share/X11/xkb/keycodes/evdev where you will see the generic scan codes next to its associated key code (other specific keyboard scan codes are listed under the "keycodes" parent folder). This applies to my keyboard which is installed as a keyboard model "Generic 105-key PC (intl.)".

In that file some of the scan codes are descriptive like <TLDE>, <LCTRL>, <SPCE>, etc., however most are not.

Okay, you now have the scan codes and key codes, but not all the key names are identified with the key codes. To get all of the key codes listed together with its associated key name, run the following command.
  • Add > keycodes.txt to the end of the command if you want the output to be in a file named "keycodes.txt", located in the working directory of the terminal. Otherwise the output will only be in the terminal.

Code: Select all

xmodmap -pke
To get individual key codes by pressing keyboard keys, run the following command (ensure that the little "Event Tester" window remains active when pressing a key):

Code: Select all

xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
Note that the above "xev" command will NOT output a key code if the key is mapped to execute an application such as "Prt" (xfce4-screenshooter [screenshot]), "F4" (Drop-down Terminal), "L-Super" (Whisker menu), etc. Those key codes can be obtained by searching the complete list of key codes as shown with the xmodmap command.

FYI, the Fn key does not have a scan code. The keyboard driver does not expose the Fn key to the operating system. When the Fn key is pressed in combination with a supported key, the keyboard driver reports a single key press to the operating system with a different scan code, essentially telling the operating system that a different key was pressed.

thomasl

Re: Changing keyboard layout bindings

#5 Post by thomasl »

The codes in those layout files are in fact not scan codes as such, I think, so I assume @Stuart_M's hints, though correct, will not really help with those definitions.

I had a page with all those <AD01> etc definitions somewhere but I couldn't find it. However, these:
https://ubuntu-mate.community/t/make-yo ... inux/19733
https://help.ubuntu.com/community/Custo ... efinitions
may perhaps help you as there are descriptions of the process as well as some images with those codes. The problem is that the codes are organised in rows and columns and so are not the same for all keyboards. I'm sure you will be able to deduct the right values for your specific hardware.

Also, when you edit that file with the definitions you have reload the keyboard layout manually for the changes to have an effect.

HTH.

thomasl

Re: Changing keyboard layout bindings

#6 Post by thomasl »

Was a double post because of SQL database problems. Can be deleted.

Post Reply

Return to “Software / Configuration”