0

I am trying to set up my computer so that the escape key performs the caps lock function and caps lock performs the escape key function. I have a small script to swap my escape and caps lock using xmodmap. In my .bash_profile, which is in my home directory, I put this line:

xmodmap ~/.capsswap

which to my knowledge, should run .capsswap, which I have in my home directory as well, when I log in.

the contents of .capsswap are

  1 ! Swap caps and Escape
  2 
  3 remove Lock = Caps_Lock
  4 keysym Escape = Caps_Lock
  5 keysym Caps_Lock = Escape
  6 add Lock = Caps_Lock

I am running Ubuntu 12.04.1 LTS.

Basically this isn't working as nothing happens on when I log in. I'm pretty new to using bash and xmodmap in general, and I could be totally wrong with what I am doing, so if anyone knows how to fix this problem, or can suggest a better way to swap the escape and caps lock, please let me know.

2 Answers 2

1

Move ~/.capsswap to ~/.Xmodmap

~/.Xmodmap is read by /etc/gdm/Xsession.

If you're not using gdm, you could add a script named: 91xmodmap

in /etc/X11/Xsession.d/

that contains:

XMODMAP="$(which xmodmap)"
SYSMODMAP="/etc/X11/Xmodmap"
USRMODMAP="$HOME/.Xmodmap"
if [ -x $XMODMAP ]; then
    if [ -f "$SYSMODMAP" ]; then
        $XMODMAP "$SYSMODMAP"
    fi
    if [ -f "$USRMODMAP" ]; then
        $XMODMAP "$USRMODMAP"
    fi
fi

The command you put in your ~/.bash_profile isn't running because gnome-terminal doesn't run as a login shell by default.

Right click on gnome-terminal's screen and go to Profiles -> Profile Preferences.

Then under the Title and Command, check Run command as a login shell.

1

Ubuntu has a GUI for changing the CapsLock behavior

Open Keyboard Layout settings and click Options. You can select the Caps Lock key behavior in there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .