Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remap Ctrl, Alt & Super keys in Ubuntu 13.10

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.

like image 406
Girish Avatar asked Feb 18 '14 05:02

Girish


2 Answers

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.

like image 164
hwjp Avatar answered Oct 01 '22 01:10

hwjp


Finally, got the keyboard to mimic the HHK layout (for the last row of the keyboard).

Had to add the command to clear the modifier keys before making the changes for the new keymap. Then, enabled the modifier keys.

clear control
clear mod1
clear mod4

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

add control = Control_L Control_R
add mod1 = Alt_L Alt_R
add mod4 = Super_L Super_R

Thank you @d4gg4d for sharing ur Xmodmap file. Else, I wouldn't have figured it out.

like image 38
Girish Avatar answered Oct 01 '22 02:10

Girish