Ubuntu – Rebind Alt key to win using setxkbmap


After an hour or two of manpage and Google searching and finding no solution or good resources, I've come for help!

I have set my Caps Lock key to Ctrl using setxkbmap -option ctrl:nocaps – this works perfectly fine.

However, since I use [awesome][1], and an IBM model M which lacks the meta key, I need my left alt key to replace the windows key. Using xkeycaps I was able to get this to work, except it killed my arrow keys and End. Problematic.

Unfortunately, documentation on setxkbmap options are sparse. and I can't find the proper option to use.

Thanks for any links/solutions.

Best Answer

setxkbmap -option altwin:swap_alt_win

The list of predefined remapping options is in /usr/share/X11/xkb/rules/evdev.lst. In this case, you probably want one of

jinx:792 Z$ grep alt /usr/share/X11/xkb/rules/evdev.lst | grep win
  altwin               Alt/Win key behavior
  altwin:menu          Add the standard behavior to Menu key
  altwin:meta_alt      Alt and Meta are on Alt keys
  altwin:ctrl_win      Control is mapped to Win keys (and the usual Ctrl keys)
  altwin:ctrl_alt_win  Control is mapped to Alt keys, Alt is mapped to Win keys
  altwin:meta_win      Meta is mapped to Win keys
  altwin:left_meta_win Meta is mapped to Left Win
  altwin:hyper_win     Hyper is mapped to Win-keys
  altwin:alt_super_win Alt is mapped to Right Win, Super to Menu
  altwin:swap_lalt_lwin Left Alt is swapped with Left Win

The Windows key is generally mapped to X11's Super modifier, and the Menu key is sometimes mapped to its Hyper modifier.

Related Question