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.

My OS is archlinux amd64, Gnome ENV.

I want to map the Caps Lock key to escape key in archlinux. I run the command:

xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'

It works well. but a moment later, the Caps Lock key works again. And I must to run the command again.

I'm pretty sure that this solution works well maybe a year agao. Waht's problem with me? Have anyone can help me to map the Caps Lock key to Escape key forever in my archlinux os?

Thanks.

share|improve this question

migrated from stackoverflow.com Mar 16 '13 at 9:10

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers

Any of the following (in increasing order of complexity):

  1. Use setxkbmap to remap the key (does not require a daemon and is independant of your desktop environment or window manager). Don't forget to add the command before the exec gnome-session (or similar) line in your ~/.xinitrc or ~/.xession.

    setxkbmap -option caps:escape
    

    setxkbmap can be found in extra/xorg-setxkbmap.

  2. dconf-editor > org.gnome.desktop.input-sources.xkb-options > Add caps:escape to the aforementionned field.

  3. gnome-session-settings > Startup Programs > Add > Name=Remap caps lock to escape, command=setxkbmap -option caps:escape
  4. Create a custom keyboard layout

FYI, I obtained the xkb rule by grepping /usr/share/X11/xkb/rules for caps and esc.

share|improve this answer
1  
The dconf method worked perfectly for me thanks! –  Keith Smiley Oct 28 '13 at 4:44
add comment

For use in X, the Arch Wiki Gnome page has instructions for modifying the keyboard with XkbOptions:

Using the dconf-editor, navigate to the key named org.gnome.desktop.input-sources.xkb-options and add desired XkbOptions (e.g. 'caps:swapescape') to the list.

In the console, you can create a custom keymap for the same effect. Create your personal keymap with the requisite changes for CapsLock and Escape at /usr/share/kbd/keymaps/i386/qwerty/yourmap then tar it and include a line in /etc/vconsole.conf to call it:

KEYMAP=yourmap
share|improve this answer
add comment

You can use xmodmap. Put your ~/.Xmodmap:

remove Lock=Caps_Lock
keysym Escape=Caps_Lock
keysym Caps_Lock=Escape
add Lock=Caps_Lock

(be sure at starting X will use your ~/.Xmodmap)

share|improve this answer
add comment

! I don't know why the answers above don't work. Here is a working one for me. In your ~/.Xmodmap

! 66 is the keycode of Caps_Lock
clear    Lock
keycode  66 = Escape 

and then

$ xmodmap ~/.Xmodmap

I'm using Fedora and non-Gnome window manager. HTH

share|improve this answer
add comment

Your Answer

 
discard

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