How to customize keymap

Hi
I want to customize keys in my urdu keyboard layout.
I am using Urdu (Pakistan) Keyboard with variant Arabic (Pakistan)
I want to swap the urdu alphabet ئ that is currently on “$” with ء that is currently on “u”

How can I do that?

1 Like

Can anybody just tell me where the keymap or keyboard layout files for different languages are located in Qubes OS so I can modify them or create a custom keymap with them?

1 Like

Qubes OS is using Fedora XFCE in dom0 so you can search how to do it in Fedora and it should be applicable for Qubes OS as well.

1 Like

Well I found out that the keymaps are located in /usr/share/X11/xkb/symbols

I tried to modify the keymap file then saved it. but then keyboard layout settings was not loading any of the keyboard layouts in that file.

Then I restore the original file and put a custom keymap file in the symbols folder.

As a result now Add keyboard layout functionality is disabled. I’ve removed the custom keymap file and restarted the system but the Add Keyboard layout button is still disabled… :confused: What should I do now?

1 Like

You can try to reinstall the package with keyboard configs:
sudo qubes-dom0-update --action=reinstall xkeyboard-config
But I’m not sure whatever it’ll help or not.
You can try asking this on Fedora forum, maybe you’ll get the answer there faster:

1 Like

An idea, let’s create the dom0 ~/.xmodmaprc file and add a keycode entry for the wanted key.

https://wiki.archlinux.org/title/Xmodmap

1 Like

What I understood from the link is that Xmodmap modify the default keyboard keymapping. I installed its guid Xkeycaps but it don’t give any option to modify keymaps of keyboard layout in a specific language.

What I need is to change keymapping of a keyboard layout in a specific language not the default one.

1 Like

I misunderstood your needs… Xmodmap is usefull for changing some keys of a layout, not the full layout.

1 Like

I don’t want to change a full layout. I just want to swap 2 keys in Urdu keyboard layout not the default one. The one on AD07 ($ on en keyboard layout) with the one on AE04 (u on en keyboard layout). That’s all.

Can xmodmap do this??

1 Like

Someone in Fedora community gave following instructions:

Keyboard layout files are stored in /usr/share/X11/xkb/symbols/

Copy the existing layout file for Urdu from the system directory to a new file in the same directory.

sudo cp /usr/share/X11/xkb/symbols/pk /usr/share/X11/xkb/symbols/pk_custom

Open the copied layout file with a text editor.

sudo nano /usr/share/X11/xkb/symbols/pk_custom

Look for the section defining the keys you want to swap. It might look something like this (you will need to adapt this to match the specific layout details of your Urdu layout):

key <AD07> { [ dollar, asciicircum,      dollar,      asciicircum      ] };
key <AE04> { [ u, U,                    u,           U                ] };

Swap the key definitions. Modify them as follows:

key <AD07> { [ u, U,                    u,           U                ] };
key <AE04> { [ dollar, asciicircum,      dollar,      asciicircum      ] };

Modify the sudo nano /etc/X11/xorg.conf.d/00-keyboard.conf and add :

Section "InputClass"
    Identifier "system-keyboard"
    MatchIsKeyboard "on"
    Option "XkbLayout" "pk_custom"
EndSection

Restart the X server or reboot the machine.

I followed the instructions. Modified 00-keyboard.conf file then restarted the system…

Now my default keyboard is urdu while my login credentials are in English. And I can’t find any way to change the language.

How am I suppose to login now?

By the way there should be an option on login screen to change keyboard layout. We can only use default keyboard on login screen.

Is there a way to login through terminal??? But I guess same problem will be there too??

Or is there a way to login in some kind of safe-mode???

Sorry I found out how to login through terminal. Revert the settings and now logged back in and back to where I was before…

It seems this system-keyboard identifier changes the default keyboard.

I just want to add the custom keyboard layout in the keyboard layouts list.

But it seems simply putting custom keymap file in /usr/share/X11/xkb/symbols folder doesn’t work.

Does anybody know here how to add a custom keyboard layout??

Try changing XkbLayout option in your /etc/X11/xorg.conf.d/00-keyboard.conf e.g. if you had:

    Option "XkbLayout" "us,pk"

Change it to:

    Option "XkbLayout" "us,pk_custom"

It only works as long as I don’t change keyboard layout settings. As soon as I add or remove something in Keyboard Layout settings, it seems then Keyboard settings ignore changes in 00-keyboard-conf file.

Anyhow by your option I found out another thing. Changing keyboard layout in Dom0 doesn’t effect keyboard layout in other qubes.

That’s why the solution was rather simple.

I was changing keymapping in Dom0 and checking results in anon-whonix and thought it’s not working.

Now I’ve simply modified the keymapping of an existing layout in dom0 and in templates and its working.

Thanks for all the support.