2

I'm having the hardest time trying to understand how xmodmap works. I want to remap the Caps Lock key to Control.

In an attempt to emaulate the answers shown here, I created the file .xmodmaprc:

clear Lock
keycode 65 = Control_L 
# I got the value 65 from running xev and pressing the key.

Then I added the following to .kshrc:

export XMODMAPRC="/Home/username/.xmodmaprc"
[ -f $XMODMAPRC ] && echo "OK" && xmodmap $XMODMAPRC

When I launch a new xterm, I can see the "OK" printed at login, but the key is still behaving as a Caps Lock!

How can I make this work?

I work on Solaris 10 and I don't have root access.

rahmu
  • 20,023

1 Answers1

3

This works for me; it swaps the Caps Lock and left Control keys.

#!/bin/sh

xmodmap - <<EOF
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Control_L
add Control = Control_L
EOF

If you want both keys to act as Control keys, you'll have to modify this; I frankly don't understand xmodmap well enough myself to do so, but this should be a good starting point.

  • It doesn't work. Did you try it on Solaris? Maybe I'm doing something wrong... – rahmu Jan 24 '12 at 10:33
  • Sorry, I haven't tried it on Solaris, and I don't have access to a Solaris X server. Ubuntu (Linux) lets you remap the control key through the preferences GUI; does Solaris have something similar? – Keith Thompson Jan 24 '12 at 10:37