Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to swap the right Win and Ctrl keys on my keyboard using xkeycaps. This the .xmodmap file that I'm loading when Ubuntu starts, generated with xkeycaps. It works fine for swapping the Esc and Caps Lock keys.

! This is an `xmodmap' input file for 
!   PC 105 key, wide Delete, tall Enter (XFree86; Spanish) keyboards.
! Automatically generated on Sun Feb  3 20:58:03 2013 by tirengarfio with
! XKeyCaps 2.47; Copyright (c) 1991-1999 Jamie Zawinski; 2005-2006 Christoph Berg.
! http://www.jwz.org/xkeycaps/
! This file presupposes that the keyboard is in the default state, and
! may malfunction if it is not.
remove Control = Control_R
remove Mod5    = Mode_switch

keycode 0x09 =  Escape  NoSymbol    Escape
keycode 0x43 =  F1  F1  F1  F1  F1  F1  XF86Switch_VT_1
keycode 0x44 =  F2  F2  F2  F2  F2  F2  XF86Switch_VT_2
keycode 0x45 =  F3  F3  F3  F3  F3  F3  XF86Switch_VT_3
keycode 0x46 =  F4  F4  F4  F4  F4  F4  XF86Switch_VT_4
keycode 0x47 =  F5  F5  F5  F5  F5  F5  XF86Switch_VT_5
keycode 0x48 =  F6  F6  F6  F6  F6  F6  XF86Switch_VT_6
keycode 0x49 =  F7  F7  F7  F7  F7  F7  XF86Switch_VT_7
keycode 0x4A =  F8  F8  F8  F8  F8  F8  XF86Switch_VT_8
keycode 0x4B =  F9  F9  F9  F9  F9  F9  XF86Switch_VT_9
keycode 0x4C =  F10 F10 F10 F10 F10 F10 XF86Switch_VT_10
keycode 0x5F =  F11 F11 F11 F11 F11 F11 XF86Switch_VT_11
keycode 0x60 =  F12 F12 F12 F12 F12 F12 XF86Switch_VT_12
keycode 0x6F =  Up  NoSymbol    Up
keycode 0x4E =  Scroll_Lock NoSymbol    Scroll_Lock
keycode 0x6E =  Home    NoSymbol    Home
keycode 0x31 =  masculine   ordfeminine masculine   ordfeminine backslash   backslash   backslash
keycode 0x0A =  1   exclam  1   exclam  bar exclamdown  bar
keycode 0x0B =  2   quotedbl    2   quotedbl    at  oneeighth   at
keycode 0x0C =  3   periodcentered  3   periodcentered  numbersign  sterling    numbersign
keycode 0x0D =  4   dollar  4   dollar  asciitilde  dollar  asciitilde
keycode 0x0E =  5   percent 5   percent onehalf threeeighths    onehalf
keycode 0x0F =  6   ampersand   6   ampersand   notsign fiveeighths notsign
keycode 0x10 =  7   slash   7   slash   braceleft   seveneighths    braceleft
keycode 0x11 =  8   parenleft   8   parenleft   bracketleft trademark   bracketleft
keycode 0x12 =  9   parenright  9   parenright  bracketright    plusminus   bracketright
keycode 0x13 =  0   equal   0   equal   braceright  degree  braceright
keycode 0x14 =  apostrophe  question    apostrophe  question    backslash   questiondown    backslash
keycode 0x15 =  exclamdown  questiondown    exclamdown  questiondown    dead_tilde  asciitilde  dead_tilde
keycode 0x16 =  BackSpace   BackSpace   BackSpace   BackSpace
keycode 0x6A =  KP_Divide   KP_Divide   KP_Divide   KP_Divide   KP_Divide   KP_Divide   XF86Ungrab
keycode 0x61 =  NoSymbol
keycode 0x63 =  Hiragana    NoSymbol    Hiragana
keycode 0x4D =  Num_Lock    NoSymbol    Num_Lock
keycode 0x70 =  Prior   NoSymbol    Prior
keycode 0x3F =  KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply XF86ClearGrab
keycode 0x52 =  KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract KP_Subtract XF86Prev_VMode
keycode 0x17 =  Tab ISO_Left_Tab    Tab ISO_Left_Tab
keycode 0x18 =  q   Q   q   Q   at  Greek_OMEGA at
keycode 0x19 =  w   W   w   W   lstroke Lstroke lstroke
keycode 0x1A =  e   E   e   E   EuroSign    cent    EuroSign
keycode 0x1B =  r   R   r   R   paragraph   registered  paragraph
keycode 0x1C =  t   T   t   T   tslash  Tslash  tslash
keycode 0x1D =  y   Y   y   Y   leftarrow   yen leftarrow
keycode 0x1E =  u   U   u   U   downarrow   uparrow downarrow
keycode 0x1F =  i   I   i   I   rightarrow  idotless    rightarrow
keycode 0x20 =  o   O   o   O   oslash  Oslash  oslash
keycode 0x21 =  p   P   p   P   thorn   THORN   thorn
keycode 0x22 =  dead_grave  dead_circumflex dead_grave  dead_circumflex bracketleft dead_abovering  bracketleft
keycode 0x23 =  plus    asterisk    plus    asterisk    bracketright    dead_macron bracketright
keycode 0x24 =  Return  NoSymbol    Return
keycode 0x6B =  Print   Sys_Req Print   Sys_Req
keycode 0x67 =  NoSymbol
keycode 0x69 =  Control_R   NoSymbol    Control_R
keycode 0x4F =  KP_Home KP_7    KP_Home KP_7
keycode 0x50 =  KP_Up   KP_8    KP_Up   KP_8
keycode 0x51 =  KP_Prior    KP_9    KP_Prior    KP_9
keycode 0x56 =  KP_Add  KP_Add  KP_Add  KP_Add  KP_Add  KP_Add  XF86Next_VMode
keycode 0x42 =  Caps_Lock   NoSymbol    Caps_Lock
keycode 0x26 =  a   A   a   A   ae  AE  ae
keycode 0x27 =  s   S   s   S   ssharp  section ssharp
keycode 0x28 =  d   D   d   D   eth ETH eth
keycode 0x29 =  f   F   f   F   dstroke ordfeminine dstroke
keycode 0x2A =  g   G   g   G   eng ENG eng
keycode 0x2B =  h   H   h   H   hstroke Hstroke hstroke
keycode 0x2C =  j   J   j   J   dead_hook   dead_horn   dead_hook
keycode 0x2D =  k   K   k   K   kra ampersand   kra
keycode 0x2E =  l   L   l   L   lstroke Lstroke lstroke
keycode 0x2F =  ntilde  Ntilde  ntilde  Ntilde  asciitilde  dead_doubleacute    asciitilde
keycode 0x30 =  dead_acute  dead_diaeresis  dead_acute  dead_diaeresis  braceleft   braceleft   braceleft
keycode 0x33 =  ccedilla    Ccedilla    ccedilla    Ccedilla    braceright  dead_breve  braceright
keycode 0x53 =  KP_Left KP_4    KP_Left KP_4
keycode 0x54 =  KP_Begin    KP_5    KP_Begin    KP_5
keycode 0x55 =  KP_Right    KP_6    KP_Right    KP_6
keycode 0x32 =  Shift_L NoSymbol    Shift_L
keycode 0x5E =  less    greater less    greater bar brokenbar   bar
keycode 0x34 =  z   Z   z   Z   guillemotleft   less    guillemotleft
keycode 0x35 =  x   X   x   X   guillemotright  greater guillemotright
keycode 0x36 =  c   C   c   C   cent    copyright   cent
keycode 0x37 =  v   V   v   V   leftdoublequotemark leftsinglequotemark leftdoublequotemark
keycode 0x38 =  b   B   b   B   rightdoublequotemark    rightsinglequotemark    rightdoublequotemark
keycode 0x39 =  n   N   n   N   n   N   n
keycode 0x3A =  m   M   m   M   mu  masculine   mu
keycode 0x3B =  comma   semicolon   comma   semicolon   horizconnector  multiply    horizconnector
keycode 0x3C =  period  colon   period  colon   periodcentered  division    periodcentered
keycode 0x3D =  minus   underscore  minus   underscore  dead_belowdot   dead_abovedot   dead_belowdot
keycode 0x3E =  Shift_R NoSymbol    Shift_R
keycode 0x62 =  Katakana    NoSymbol    Katakana
keycode 0x57 =  KP_End  KP_1    KP_End  KP_1
keycode 0x58 =  KP_Down KP_2    KP_Down KP_2
keycode 0x59 =  KP_Next KP_3    KP_Next KP_3
keycode 0x6C =  ISO_Level3_Shift    NoSymbol    ISO_Level3_Shift
keycode 0x25 =  Control_L   NoSymbol    Control_L
keycode 0x73 =  End NoSymbol    End
keycode 0x40 =  Alt_L   Meta_L  Alt_L   Meta_L
keycode 0x41 =  space   NoSymbol    space
keycode 0x71 =  Left    NoSymbol    Left
keycode 0x74 =  Down    NoSymbol    Down
keycode 0x75 =  Linefeed    NoSymbol    Linefeed
keycode 0x6D =  Next    NoSymbol    Next
keycode 0x64 =  Henkan_Mode NoSymbol    Henkan_Mode
keycode 0x68 =  KP_Enter    NoSymbol    KP_Enter
keycode 0x66 =  Muhenkan    NoSymbol    Muhenkan
keycode 0x5A =  KP_Insert   KP_0    KP_Insert   KP_0
keycode 0x5B =  KP_Delete   KP_Decimal  KP_Delete   KP_Decimal

add    Control = Control_R
add    Mod1    = 0x00CD
add    Mod4    = Super_L Super_R 0x00CE 0x00CF
add    Mod5    = ISO_Level3_Shift Mode_switch
share|improve this question

1 Answer 1

up vote 0 down vote accepted

If your only aim is to swap Ctrl and Caps Lock, then the file you're generating might be a bit overkill.

I use setxkbmap to change the layout, as xmodmap has failed across THE setup of my various machines:

setxkbmap -option rctrl:swapcaps

and I put that into my .xinitrc

Also note that when experimenting, setxkbmap -option resets everything back to the initial layout.

EDIT: I found this over on http://askubuntu.com, which also describes resetting using setxkbmap

share|improve this answer

Your Answer


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.