Doing simple keyboard remapping in Plasma 6 (Success!)

I am using Plasma 6.5 in the Fedora KDE Edition. I needed to do some keyboard remapping, but was unable to install Keyd, and Input-Remapper has apparently been withdrawn for Fedora.

So I figured out how to do what I needed, under the hood. Oddly, even though the change is made in an X11 sub-folder, the method works in Wayland.

My needs: (1) Make KeyPad-5 to be a delete key. This is very handy because it is in the middle of the 4 arrow keys, and it has a tactile bar which makes it easy to avoid inadvertent character deletions. I used this on a Windows computer the last 5 years, and only mistyped that key twice! (2) Make the KeyPad-Insert and the real KeyPad-Delete keys inoperative, since those ones I do often accidentally bump.

Method: The keypad keymap is in the file /usr/share/X11/xkb/symbols/keypad. On lines 11, 37 and 72 the action for is KP_Begin (which is a nul action). Carefully change the action to KP_Delete, not otherwise disturbing the structure of the text. Then I set KP_Begin as the action for keys and , and saved the file. The changes took effect after a reboot, and may need to be redone after future Plasma updates.

Similarly, there are other keymaps for the other keys on the keyboard in the files /usr/share/X11/xkb/symbols/pc (shift keys, etc.) and … /US (character keys & function keys). The latter is a long file with many keymaps (international, Dvorak, etc.), so it will take some looking to find the right one.

It’s still available in the repositories, is it not working?

Nothing wrong with customising the keymap though, rather than inserting input-remapper as an extra processing step.

1 Like

Yeah, I tried that link and got a “Status Code: 404…” error (and did again just now). Some other sites say it was withdrawn.

No, it’s still there and can be installed on Fedora 43 if you want it:

$ dnf install input-remapper --assumeno
Updating and loading repositories:
Repositories loaded.
Package                                Arch       Version                                Repository               Size
Installing:
 input-remapper                        noarch     2.2.0-1.fc43                           updates               2.0 MiB
Installing dependencies:
 gtksourceview4                        x86_64     4.8.4-10.fc43                          fedora                4.5 MiB
 python3-annotated-types               noarch     0.7.0-8.fc43                           fedora               85.1 KiB
 python3-dns                           noarch     2.8.0-2.fc43                           fedora                3.5 MiB
 python3-email-validator               noarch     2.3.0-2.fc43                           fedora              187.4 KiB
 python3-evdev                         x86_64     1.9.1-5.fc43                           fedora              559.7 KiB
 python3-pydantic                      noarch     2.12.5-1.fc43                          updates               5.1 MiB
 python3-pydantic-core                 x86_64     2.41.5-1.fc43                          updates               5.5 MiB
 python3-pydbus                        noarch     0.6.0-33.fc43                          fedora              149.4 KiB
 python3-setuptools                    noarch     78.1.1-15.fc43                         fedora                9.0 MiB
 python3-typing-inspection             noarch     0.4.2-1.fc43                           updates              91.9 KiB
Installing weak dependencies:
 python3-pydantic+email                noarch     2.12.5-1.fc43                          updates               0.0   B

Transaction Summary:
 Installing:        12 packages

Total size of inbound packages is 7 MiB. Need to download 7 MiB.
After this operation, 31 MiB extra will be used (install 31 MiB, remove 0 B).
Operation aborted by the user.

There were some initial problems with input-remapper on Fedora 43 (because input-remapper had dependencies that weren’t fully compatible with Python 3.14), but with version 2.2.0 (the current one available) it’s reported to work fine.

I just got it installed. Thanks.

1 Like

i would advise anyone wanting to modify these root level files to make a backup before starting in, such as:

cp /usr/share/X11/xkb/symbols/keypad /usr/share/X11/xkb/symbols/keypad-bak

esp when it comes to the main layout for your language like /usr/share/X11/xkb/symbols/us

because a misplaced character or missing paren can render you unable to even type in a password at the tty screen.

that’s when you boot to grub (or a live USB) and rename the backup file to restore the defaults.

i would also suggest that it’s better to make a new variant, rather than tinker with the core definitions.

then you can just paste in an entire section that you can keep in a text file like i’ve one for my custom symbols layout

If you do that, you can also avoid writing anything to /usr. (In fact, on KDE Linux and other immutable distros, it’s impossible to write there.)

Possible locations are:

  1. $XDG_CONFIG_HOME/xkb/, or $HOME/.config/xkb/ if the $XDG_CONFIG_HOME is not defined
  2. $HOME/.xkb/
  3. $XKB_CONFIG_EXTRA_PATH/xkb if $XKB_CONFIG_EXTRA_PATH is defined, otherwise <sysconfdir>/xkb (mostly this is /etc/xkb)
  4. $XKB_CONFIG_ROOT/X11/xkb if $XKB_CONFIG_ROOT is defined, otherwise <datadir>/X11/xkb/ (mostly this is /usr/share/X11/xkb)

(Source: “Codeaffen”, which I found very useful for learning about this.)

i tried that approach initially but my instance of kubunu 24.04 did not like or use those directories as described by X.org.

have you done this, and did it work?

what distro did it work on?

i didn’t try defining the variables for myself in .profile tho, maybe that would be the next step.

I have this working in Fedora, using $HOME/.xkb. (No particularly good reason why I chose that over $HOME/.config/xkb really).

Under that dir, I have:

rules/evdev
rules/evdev.xml
symbols/my-layout

“In fact, on KDE Linux and other immutable distros, it’s impossible to write there”, in /usr.

It seems that isn’t correct, since that’s what I did (or is “KDE Linux something else entirely?–it’s confusing), and :

  $cat /etc/os-release
  NAME=”Fedora Linux”
  Version=43 (KDE Plasma Desktop Edition)

i’m going to try again….

did you add the environment variables or do you just let X look in your /home?

and you have

rules/evdev

or

rules/evdev.lst

Yes! I mean specifically KDE’s own immutable Linux distribution called KDE Linux, not “any Linux distribution with KDE Plasma as the desktop environment”.

I just let it look in my home. (Actually, maybe that was why I chose ~/.xkb out of the various choices available.)

rules/evdev - yes

rules/evdev.lst - no

And also rules/evdev.xml - yes

1 Like

did you make changes to this file from the one that exists in X11?

here i assume this is a copy of the one from X11with the added section to describe your new variant?

this is where it gets complicated for me.

i don’t know if i should just copy the entire us key where my variant is included, or should i just have a file with the partial alphanumeric_keys modifier_keys line at the top

I made a simple 3-line file following the example in the Codeaffen article. The idea is to “include” the main file rather than duplicating any data, and have an entry specifically for your custom layout.

No copied data - just the specific block that defines the new variant. Again along the lines of the Codeaffen example.

I did it more like the latter (and again like the Codeaffen example symbols file). Start with the partial ... line, have an include statement for the layout you’re deriving from, and just have entries for the keys that you want to change.

1 Like

cant’ make it go.

followed the website directions to a T and even added the symlink back to my layout in the root folder, and tried both ~/.xkb and ~/.config/xkb as well as defining the variable XDG_CONFIG_HOME in my .profile

the plasma keyboard settings page does not find the new layout.

i can use setxkbmap gng and use the new map for the session, so that tells me at least part of the codeaffin scheme is working, but it’s not playing nice with my plasma 5 kubuntu.

here is what i got, in case you can see something i can’t

symlink

directories

~/.config/xkb/rules/evdev

! option   = symbols
  gng:geek  = +gng(geek)

! include %S/evdev

~/.config/xkb/rules/evdev.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
<xkbConfigRegistry version="1.1">
  <layoutList>
    <layout>
      <configItem>
        <name>gng</name>
        <shortDescription>geek</shortDescription>
        <description>English (US, Greek and Geek)</description>
        <countryList>
          <iso3166Id>US</iso3166Id>
        </countryList>
        <languageList>
          <iso639Id>eng</iso639Id>
        </languageList>
      </configItem>
    </layout>
  </layoutList>
</xkbConfigRegistry>

~/.config/xkb/symbols/gng

// US Symbolic-Greek and Geek
// Author: droidgoo@proton.me
// based on us(symbolic) with many added symbols and improved organization
// while keeping the unique greek letters for science/engineering work
// paste this section at the end of /usr/share/X11/xkb/symbols/us
// the variant will be the text as shown in xkb_symbols "<variant>"
// use "<variant>" for "XkbVariant" in /etc/X11/xorg.conf.d/00-keyboard.conf
// GUI listings will show text defined in line name[Group1]= "English (US, Variant Desc Text)"


partial alphanumeric_keys modifier_keys
xkb_symbols "geek" {

    include "us(basic)"
    include "us(symbolic)"
    name[Group1]= "English (US, Greek and Geek)";

    key <TLDE> { [ NoSymbol,   NoSymbol,    U2241,              approxeq            ] }; // ` ~ ≁ ≈
    key <AE01> { [ NoSymbol,   NoSymbol,    U220E,              because             ] }; // 1 ! ∎ ∵
    key <AE02> { [ NoSymbol,   NoSymbol,    twosuperior,        therefore           ] }; // 2 @ ² ∴
    key <AE03> { [ NoSymbol,   NoSymbol,    threesuperior,      numerosign          ] }; // 3 # ³ №
    key <AE04> { [ NoSymbol,   NoSymbol,    U25FE,              cent                ] }; // 4 $ ◾ ¢
    key <AE05> { [ NoSymbol,   NoSymbol,    dagger,             doubledagger        ] }; // 5 % † ‡
    key <AE06> { [ NoSymbol,   NoSymbol,    squareroot,         infinity            ] }; // 6 ^ √ ∞
    key <AE07> { [ NoSymbol,   NoSymbol,    section,            paragraph           ] }; // 7 & § ¶
    key <AE08> { [ NoSymbol,   NoSymbol,    multiply,           division            ] }; // 8 * × ÷
    key <AE09> { [ NoSymbol,   NoSymbol,    enfilledcircbullet, periodcentered      ] }; // 9 ( • ·
    key <AE10> { [ NoSymbol,   NoSymbol,    degree,             U2300               ] }; // 0 ) ° ⌀
    key <AE11> { [ NoSymbol,   NoSymbol,    emdash,             endash              ] }; // - _ — –
    key <AE12> { [ NoSymbol,   NoSymbol,    notequal,           plusminus           ] }; // = + ≠ ±

    key <AD01> { [ NoSymbol,   NoSymbol,    U21D1,              U21D3               ] }; // q Q ⇑ ⇓
    key <AD02> { [ NoSymbol,   NoSymbol,    U21D2,              U21D0               ] }; // w W ⇒ ⇐
    key <AD03> { [ NoSymbol,   NoSymbol,    Greek_epsilon,      U22EE               ] }; // e E ε ⋮
    key <AD05> { [ NoSymbol,   NoSymbol,    Greek_tau,          U156F               ] }; // t T τ ᕯ
    key <AD08> { [ NoSymbol,   NoSymbol,    Greek_iota,         U2051               ] }; // i I ι ⁑
    key <AD09> { [ NoSymbol,   NoSymbol,    Greek_omicron,      U204E               ] }; // o O ο ⁎
    key <AD11> { [ NoSymbol,   NoSymbol,    guillemetleft,      U2039               ] }; // [ { « ‹
    key <AD12> { [ NoSymbol,   NoSymbol,    guillemetright,     U203A               ] }; // ] } » ›
    key <BKSL> { [ NoSymbol,   NoSymbol,    U1F6C7,             brokenbar           ] }; // \ | 🛇 ¦

    key <AC01> { [ NoSymbol,   NoSymbol,    Greek_alpha,        U2659               ] }; // a A α ♙
    key <AC06> { [ NoSymbol,   NoSymbol,    Greek_eta,          U2656               ] }; // h H η ♖
    key <AC08> { [ NoSymbol,   NoSymbol,    Greek_kappa,        U2654               ] }; // k K κ ♔
    key <AC10> { [ NoSymbol,   NoSymbol,    uparrow,            downarrow           ] }; // ; : ↑ ↓

    key <AB01> { [ NoSymbol,   NoSymbol,    Greek_zeta,         U0277               ] }; // z Z ζ ɷ
    key <AB02> { [ NoSymbol,   NoSymbol,    Greek_chi,          UA66B               ] }; // x X χ ꙫ
    key <AB05> { [ NoSymbol,   NoSymbol,    Greek_beta,         U2657               ] }; // b B β ♗
    key <AB06> { [ NoSymbol,   NoSymbol,    Greek_nu,           U2658               ] }; // n N ν ♘
    key <AB07> { [ NoSymbol,   NoSymbol,    Greek_mu,           U2655               ] }; // m M μ ♕
    key <AB08> { [ NoSymbol,   NoSymbol,    lessthanequal,      U2303               ] }; // , < ≤ ⌃
    key <AB09> { [ NoSymbol,   NoSymbol,    greaterthanequal,   U2304               ] }; // . > ≥ ⌄
    key <AB10> { [ NoSymbol,   NoSymbol,    U262E,              U262D               ] }; // / ? ☮ ☭

    include "level3(ralt_switch)"
};


I can’t see a problem, sorry :frowning:

so close i can taste it… but i’m going to revert back to my edit of the root dir because that simply works.

thanks for the help.

1 Like

No worries. Maybe park it and give it another go when Plasma 6 reaches you?

1 Like