Can't change any keys with xmodmap

I’m a linux/manjaro newby and I’m trying to use xmodmap to change the location of the “greater” and “less” keys, since I’m currently using a keyboard that doesn’t have the key for that in the language I use.

All I want to do is change them to the place of the “period” and “comma”, and to use them press CRT_L and ALT_L. I searched a bit and it seemed to me impossible. So, I tried to make it so to use them I need to press ALT_R. But even like that I can’t make it work.

I created the ~/.Xmodmap file, and there I added the contents of xmodmap -pke sligthy modified.

I only changed the two keys I was interested in, doing:

keycode 59 = comma semicolon comma semicolon less
keycode 60 = period colon period colon greater

Then with the comand xmodmap ~/.Xmodmap the changes were supposed to be made.
The thing is that nothing changed, even though in xev, the changes are noticeable.

What am I doing wrong? Thanks for the help:)

You may need to enable third level shift in your keyboard preferences.

If that doesn’t help. xmodmap is deprecated, xkbcomp is newer and better but more complex.

I don’t know what keyboard or language you’re using so this is based on mine. Your keys may be different (mine are from a UK keyboard which has less and greater already mapped to level 2).

Dump the config.

xkbcomp $DISPLAY ~/.xkbmap

As you may already know, Alt_R is usually level 3 so we switch out the 3rd symbol, like so:

# this is in the 4th section "symbols"
key <AB08> {
        type= "FOUR_LEVEL",
        symbols[Group1]= [           comma,            less,           less,        multiply ]
    key <AB09> {
        type= "FOUR_LEVEL",
        symbols[Group1]= [          period,         greater,  greater,        division ]

Then save it and re-apply the config:

xkbcomp ~/.xkbmap $DISPLAY

This is only temporary, you need to run it each time you log in. xmodmap is the same, except there’s code in ~/.xinitrc than looks for and loads the config. You should be able to do the same for xkbcomp.

if [ -f "$userxkbmap" ]; then
    xkbcomp "$userxkbmap" $DISPLAY

If it’s an external keyboard you should make a udev rule to load the map again if the keyboard is re-connected (AFAIK same goes for xmodmap).


1 Like

Thanks a lot! I solved the problem by changing from Wayland to Xorg, it seems that xmodmap doesnt work well with wayland.

The Udev advice is going to be really helpfull since I am constantly connecting different keyboards:)

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.