2

I am on a lenovo thinkpad running manjaro and I want to swap the right alt key and the prtsc key using setxkbmap. Lenovo puts the prtsc where right alt should be and is driving me nuts.

I followed the top answer from Use setxkbmap to swap the Left Shift and Left Control and made my myswap file to be

partial modifier_keys
xkb_symbols "swap_ralt_prsc" {
    replace key <RALT>  { [ Print ] };
    replace key <PRSC> { [ Alt_R ] };
};

but it doesn't work. It only works to make right alt become print screen but the print screen button doesn't become right alt. So maybe the 2nd replace line is not correct? I checked other examples online and I believe the syntax is right.

Am I missing something? I think some computers have prtsc paired with sysrq. Would that matter in this case?

  • i'm no expert at all, but based on my failed attempts, i think it may be that whatever reacts to pressing is catching it in a layer that is prior to xkb. e.g. i think the window manager is listening into the key event pipeline prior to xkb. – Attila Lendvai Apr 19 '21 at 21:24

1 Answers1

1

I didn't have any success using setxbmap, but if you are okay with using a different tool, xmodmap seems to be able to do the job.

I made a file that has the desired configuration (in ~/.config/xmodmap/xmodmap.conf for me. I also didn't care about putting print screen anywhere else, but you are welcome to do that.):

keycode 107 = Alt_R Meta_R Alt_R Meta_R

This runs on startup from my .xinitrc as an argument to the xmodmap command in this line:

[[ -f .config/xmodmap/xmodmap.conf ]] && xmodmap .config/xmodmap/xmodmap.conf

P.S. You can find the keycode of your print screen key using xev. Just launch the program, hit the key, and you will see the keycode printed out in stdout.