Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

There is no such option in Keyboard Layout Options which is sad.

How can I do it manually?

share|improve this question
    
Answer is pretty much a dupe of my answer here: askubuntu.com/questions/23491/… –  djeikyb Jan 7 '12 at 20:07

2 Answers 2

up vote 5 down vote accepted

To do this manually you want to create a file called .Xmodmap in your home directory. You could do this using a command from the terminal

~$ gedit ~/.Xmodmap

That will create the file and open it in gedit. Add the following lines to the file:

clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 64 = Control_L
add control = Control_L Control_R
add mod1 = Alt_L Meta_L

Save the file and quit gedit. Next time you login the new keymappings will be active. To have the settings take immediate effect run the following command:

~$ xmodmap ~/.Xmodmap

There's a chance that the keycodes above are different on your computer. If the above doesn't work, try running the xev program from the command line. Xev will generate a new small window in the corner of your screen. If you start pressing keys on your keyboard you’ll get all the key mapping information for that key press.

~$ xev

For example if I press “q” when xev is running I get the following output:

KeyRelease event, serial 33, synthetic NO, window 0x4c00001,
root 0xb6, subw 0x0, time 9127480, (21,-17), root:(22,36),
state 0x0, keycode 24 (keysym 0x71, q), same_screen YES,
XLookupString gives 1 bytes: (71) "q"
XFilterEvent returns: False

keycode 24 is the information that we're after. Press your left Ctrl and left Alt buttons while running xev to get your own respective keycodes to confirm that they are the same as the ones used above.

Hope that helps.

share|improve this answer

Simply create ~/.Xmodmap using a simple text editor and restart the Xserver.


!
! based on: http://www.emacswiki.org/emacs/SwapControlAltAndCapsLock#toc8
!

!----------------------------------------------------------
! Swap Control and Alt keys, both sides
!----------------------------------------------------------

! First clear all modifiers & control
clear control
clear mod1
clear mod4

! Swap Control_L and Alt_L
keycode  64 = Control_L
keycode  37 = Alt_L Meta_L

! Menu becomes Alt_R Meta_R (AltGr)
keycode 135 = Alt_R Meta_R

! Define Control_R and Alt_R similar to Control_L and Alt_L
keycode 108 = Control_L
keycode 105 = Alt_L Meta_L

! We need to set keycodes first, as some programs (emacs!) read
! the key names and seem to ignore what's below.
add mod1    = Alt_L Alt_R Meta_L Meta_R
add mod4    = Super_L Super_R
add control = Control_L Control_R


!------------------------------------------
! Caps_Lock becomes an additional BackSpace
!------------------------------------------
remove lock = Caps_Lock
keysym Caps_Lock = BackSpace
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.