I am using a new keyboard, and trying to set it up to mimic the keyboard on my laptop. I'm using xmodmap on Ubuntu 14.04, and can't get it to work. I cleared the modifier keys like so :

xmodmap -e "clear mod1"
xmodmap -e "clear mod4"
xmodmap -e "clear Control"

And that works fine, afterwards the modifiers don't do anything. After that, I try to assign the Alt_R key to act as a super key, like so :

xmodmap -e "add mod1 = Alt_R"

However, the alt button then goes back to behaving like an alt button, instead of behaving like super and bringing up the Unity search when it's tapped. Is there a trick to getting the modifiers working with xmodmap?

Additionally, even after clearing control, with "xmodmap -e "clear Control", I can still use ctrl.

The keyboard I'm using is the das keyboard s ultimate, if that matters at all.

EDIT: A realization I made while messing around with xev and trying to solve the problem : When I run something like "xmodmap -e "keycode 133 = Alt_L" (keycode 133 is usually super), and then launch xev, when I look at the output it shows this :

KeyRelease event, serial 37, synthetic NO, window 0x2000001,
root 0x9e, subw 0x0, time 179020, (-382,66), root:(406,118),
state 0x40, keycode 133 (keysym 0xffe9, Alt_L), same_screen YES,
XKeysymToKeycode returns keycode: 64
XLookupString gives 0 bytes: 
XFilterEvent returns: False

As you can see, it sees the key press as Alt_L. However, the key is still behaving like a super key, activating the Unity search when pressed.

1 Answer 1


I'm not an expert myself, but I'll give it a try. First of all, let us make an xmodmap script at ~/.Xmodmap. I understand you want the right alt to function as a super key. I suggest this:

clear mod1
clear mod4

!Make right alt to look like Super_R
!I'm assuming your right alt has keycode 108, you can check using xev
keycode 108 = Super_R NoSymbol Super_R

!Add the Super_L and Super_R keys to the modifier mod4
add mod4 = Super_L Super_R

Your other alt key and super keys may now be messed up, but you can assign them to anything you want analogously. (If you don't want to change them at all, use xev to see what they did originally and assign them to that.) Just put all clears together first, then the assignings of keycodes to key names, then finally the assignings of key names to modifiers, and I think it should work. Normally, ~/.Xmodmap should be executed automatically on login, but if not, you can try adding a line

xmodmap ~/.Xmodmap


sleep 4 && xmodmap ~/.Xmodmap &

to ~/.bash_profile.

  • 1
    When swapping modifiers, why is it necessary to mess with keycodes? Why not just operate purely on the keysym level? Commented Jul 21, 2018 at 20:53
  • This is just some solution that works, probably not the only one or the best one. So if you have an alternative that might be preferrable, do post an answer!
    – dremodaris
    Commented Jul 23, 2018 at 10:26
  • No, everywhere I look, this is what people suggest. I just don't have a good enough understanding of Xmodmap to get why all the steps are necessary :( Commented Jul 23, 2018 at 15:36
  • I think the reason is that some programs and frameworks look for individual keysyms, so you want to remap them too rather than just changing the modifiers around. Commented Aug 19, 2018 at 0:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .