-   Linux - Newbie (
-   -   How do I remap Alt to a Super Key? (

fhsm 01-12-2009 08:12 PM

How do I remap Alt to a Super Key?
I've got a laptop that doesn't include a super / windows key. I find this very frustrating. When I had windows on this computer I had mapped one of my alt keys to act like the windows key. I'd like to accomplish the same thing on linux how can I do this?

I tried to make ~/.Xmodmap with the following:

keycode 108 = Super_R NoSymbol Super_R NoSymbol Super_R
keycode 134 = Alt_R Meta_R Alt_R Meta_R Alt_R Meta_R

Then I ran

xmodmap ~/.Xmodmap
Then I ran xev and pressed the right alt key (108) and got:

KeyPress event, serial 35, synthetic NO, window 0x2200001,
    root 0x65, subw 0x0, time 1298472, (286,-242), root:(897,395),
    state 0x0, keycode 108 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

This suggested to me that it had worked; however, when testing a keyboard shortcut that required the super key it did not work. Next I tested a shortcut that requires an alt key and it did work.

Clearly I don't know what I'm doing. Can someone please help me?

maroonbaboon 01-13-2009 06:56 PM

Just a guess (I am also confused by keyboard layouts) but maybe you need to reset Alt_R as a modifier. Run xmodmap -pm to see your current modifiers. I get:

mod1 Alt_L (0x40), Alt_R (0x71), Meta_L (0x9c)
mod4 Super_L (0x7f), Hyper_L (0x80)

(among other stuff). So maybe something like

remove mod1 = Alt_R
add mod4 = Alt_R

would have the required effect.

fhsm 01-14-2009 04:06 PM


keycode 108 = Super_R
remove mod1 = Super_R
add mod4 = Super_R

did the trick, thanks!

One problem: this doesn't survive a reboot. The key mapping part sticks and the remove but not the add. Here's what I get after reboot:

$ xmodmap -pk | grep 108
  108            0xffec (Super_R)
$ xmodmap -pm
  mod1        Alt_L (0x40),  Super_R (0x6c),  Meta_L (0xcd)
  mod4        Super_L (0xce),  Hyper_L (0xcf),  Super_R (0x6c)

I can fix this from a restart with either

xmodmap ~/.Xmodmap

xmodmap -e 'remove mod1 = Super_R'
I've tried sudo-ing the ~/.Xmodmap bit but still it doesn't stick. Any suggestions? I find it odd that part of my custom file would get applied but not all...

maroonbaboon 01-14-2009 06:12 PM

I've also had the experience of trying to set X resources and having them mysteriously clobbered. I never figured out in any detail what was happening. But as far as I can see on my Debian system the desktop config file ~/.gnomerc gets the last bite on startup so I would give that (or your equivalent) a go for running xmodmap.

fhsm 01-15-2009 06:40 AM

@ marronbaboon Thanks for that suggestion.

Just out of curiosity I tried changing .Xmodmap to:

keycode 108 = Super_R
remove mod1 = Super_R
add mod4 = Super_R
remove mod1 = Alt_R

This results in an error on

xmodmap ~/.Xmodmap
but gets me correct behavior on startup.

Many hours later this is a total black box.

All times are GMT -5. The time now is 09:44 AM.