On Wayland, xmodmap
seems to not be effective anymore, but XKB is ... and here is what I just did on my system:
First, I searched the files under /usr/share/X11/xkb/
(that's where your keyboard's data is defined) for the name of my keyboard's Microphone Muting key i.e. XF86AudioMicMute
(those MultiMedia keys have names, please see the other linked answer below) like so:
$ grep -r -i 'XF86AudioMicMute' /usr/share/X11/xkb/
/usr/share/X11/xkb/symbols/inet: key <FK20> { [ XF86AudioMicMute ] };
/usr/share/X11/xkb/symbols/inet: key <I256> { [ XF86AudioMicMute ] }; // KEY_MICMUTE
... that shows two lines in the file /usr/share/X11/xkb/symbols/inet
, and then I edited that file like so:
sudo gedit /usr/share/X11/xkb/symbols/inet
... then, commented out the two lines above and copied each one beneath it changing them to look like this:
# key <FK20> { [ XF86AudioMicMute ] };
key <FK20> { [ BackSpace ] }; // KEY_MICMUTE_REMAPED
...
key <I256> { [ XF86AudioMicMute ] }; // KEY_MICMUTE
key <I256> { [ BackSpace ] }; // KEY_MICMUTE_REMAPED
... leaving the rest of the other lines alone ... then, saved the file and logged out of my user's current desktop session and then logged in back again ... and, voila, my Microphone Mute key is now remapped to be a BackSpace key.
If you want to know more information about MultiMedia keys, please see my other (old) answer here.
It's worth noting as well that you can further limit the files of interest under /usr/share/X11/xkb
to modify any key in your currently active layout for your currently active keyboard with setxkbmap
used like so:
setxkbmap -print -verbose 10
... which gives output like this:
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules: evdev
model: pc105
layout: us
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+us+inet(evdev)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+us+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
... where each include
next to each section e.g. xkb_symbols
refers to related filenames to that section e.g. pc
, us
and inet
.
sudo showkey
: does that show a code? If using Gnome Shell, try the command:gsettings set org.gnome.settings-daemon.plugins.media-keys mic-mute-static ['']
. If it works, it will at least remove the key binding so hitting it does not anymore interfere. – vanadium Oct 25 '23 at 15:04/usr/share/X11/xkb/symbols/hp_vndr/us
haskey <SYST> { [ hpSystem ]};
so keep that in mind too ... i.e. each keyboard is different and only the one laying hands on it can identify it ... My answer is an example on my keyboard ... I never said it's going to be easy :-) – Raffa Nov 05 '23 at 15:35