Remap Ctrl, Alt & Super keys in Ubuntu 13.10

Girish picture Girish · Feb 18, 2014 · Viewed 13.3k times · Source

I'm trying to remap the last row of my keyboard to mimic the Happy Hacking Keyboard layout. I created a .Xmodmap file with following the keycode changes. The below shows only the lines that have been changed manually in the Xmodmap file generated using xmodmap -pke > ~/.Xmodmap.

keycode 37 = Super_L NoSymbol Super_L
keycode 64 = Control_L NoSymbol Control_L
keycode 105 = Super_R NoSymbol Super_R
keycode 108 = Control_R NoSymbol Control_R
keycode 133 = Alt_L Meta_L Alt_L Meta_L
keycode 134 = Alt_R Meta_R Alt_R Meta_R

The above changes were loaded using

xmodmap ~/.Xmodmap

The changes were verified from running xev i.e. Alt key: Ctrl, Super key: Alt and Ctrl key: Super.

However, when I run emacs, it is still Alt key: Alt, Super key: Super & Ctrl key: Ctrl. And, the terminal can still be launched only by pressing Alt + Ctrl + t instead of Alt + Super + t. These applications still reflect the default keyboard layout, not in accordance to the new configuration in my $HOME/.Xmodmap file.

Added the xmodmap ~/.Xmodmap to the $HOME/.xinitrc file so that the changes are persistant across applications. This did not the work.

Also, added the following code to /etc/X11/xinit/xinitrc. But this did not work either.

if [ -f $HOME/.Xmodmap ]; then
    /usr/bin/xmodmap $HOME/.Xmodmap
fi

Kindly provide your suggestions.

Thank you for your time.

-Girish

A little backgroud:

Recently switched to Ubuntu from Windows. I use Emacs for writing code and have found it effective to map the keys as in HHK. It avoids hurting the pinky and RSI of the wrists.

Answer

hwjp picture hwjp · Dec 18, 2014

For info, if you don't want to get into the pain of Xmodmap, you can also do a lot via gnome settings.

sudo apt-get install gnome-tweak-tool, open it, go to Typing, and check out the options for Ctrl key position and Alt/Win key behaviour:

enter image description here

You could probably also do this stuff via gsettings, but am not sure of the exact config entry name.