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
  • 19,673
  • 28
  • 87
  • 128
  • 1
    [Not .kshrc](http://unix.stackexchange.com/questions/3052/alternative-to-bashrc/3085#3085), but your X session startup script. I don't know what that is for Solaris 10. – Gilles 'SO- stop being evil' Oct 31 '12 at 22:09
  • I finally got it. I'm accessing a Solaris server from a Windows host and I run X locally. It was [Exceed](http://connectivity.opentext.com/products/exceed-products.aspx) that needed remapping. X's notion of server/client is confusing. [Here's how to do it on Exceed](http://nstx.pppl.gov/nstx/Software/FAQ/exceedtips.html). @Gilles thanks for your comment, it led me in the right direction. – rahmu Nov 22 '12 at 21:47

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.

Keith Thompson
  • 21,782
  • 6
  • 48
  • 55
  • 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