Unfortunately, the configuration at the and of this post does not work for Wayland Qt applications, like konsole, kate. A colleage from KDE Brazil telegram channel pointed me to a working solution.
Update 28/12/2021: the configuration below works for X11/XWayland applications only.
Going forward with migrating to Wayland. There are several smalls things to fix in my setup, one of them is adding a custom layout to workaround the fact that my child broken the Up key of my laptop's keyboard. I had mapped F9 to Up using $HOME/.Xmodmap, which does not work in Wayland. I have figure out how to that in Wayland [1] [2] and maybe this can help other people.
Create this file to configure XDG_CONFIG_HOME variable:# /etc/profile.d/xdg.sh
export XDG_CONFIG_HOME=$HOME/.config
Create the $HOME/.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>lvs</name> <!-- Change to any name you want -->
<shortDescription>Layout LVS</shortDescription> <!-- Same here -->
<description>Layout com F8, F9 e F10 remapeadas</description> <!-- Any description you want -->
<countryList>
<iso3166Id>US</iso3166Id> <!-- Add your country to this list -->
<iso3166Id>BR</iso3166Id> <!-- My country: Brazil -->
</countryList>
<languageList>
<iso639Id>eng</iso639Id> <!-- Layout language -->
<iso639Id>por</iso639Id> <!-- Brazilian Portuguese -->
</languageList>
</configItem>
</layout>
</layoutList>
</xkbConfigRegistry>
Create a file $HOME/.config/xkb/symbols/lvs (the file name have to match the layout name in evdev.xml) with the actual changes you need. I just copied the file with the symbols I wanted to change to save time:
cp /usr/share/X11/xkb/symbols/srvr_ctrl $HOME/.config/xkb/symbols/lvs
Then I removed all lines that should not be changed. The final file is the following (the actual changes are in bold):
partial function_keys
xkb_symbols "fkey2vt" {
key <FK08> {
type="CTRL+ALT",
symbols[Group1]= [ Prior, F8, F8, F8, XF86_Switch_VT_8 ]
};
key <FK09> {
type="CTRL+ALT",
symbols[Group1]= [ Up, Prior, F9, F9, XF86_Switch_VT_9 ]
};
};
Comparing all this to the .Xmodmap it seems way more complicated :-( This is my .Xmodmap:
! 74 = F8
keycode 74 = Prior
! 75 = F9
keycode 75 = Up Prior
You need to restart startplasma-wayland so the changes take affect. The best part is that it also works with X11, so I removed my .Xmodmap.
PS: the Up key does not work in konsole to show the previous command when running in wayland, even with an external keyboard with a physical Up key. That works in X11.