[buug] remapping with xmodmap: help me save my carpel tunnel!

Michael Paoli mp at rawbw.com
Tue Jan 18 08:21:09 PST 2005


Quoting TN <eyefull at eml.cc>:

> Hi, I'm new to this list. I'd like to do the following with xmodmap but
> somehow can't figure how:
> -map the right alt key to shift (so i can use my thumb when reaching for
> the _ or + or | characters)
> -swap the escape key with the tilde key (I'm a vi user)

I presumed that by default your asciitilde is on the same key as your
grave (`) and you'd use the shift modifier with that key to get
asciitilde, and not use the shift modifier to get grave, and that you
want to swap that functionality with that of key with the escape key.

Your keycodes may vary.
These may also be helpful:
http://web.mit.edu/answers/xwindows/xwindows_xmodmap.html
xev(1)
xkeycaps(1)

$ { xmodmap -pk; xmodmap -pm; } | fgrep -i 'Alt_R
> Shift_R
> mod1
> Escape
> asciitilde'
      9         0xff1b (Escape)
     49         0x0060 (grave)  0x007e (asciitilde)
     62         0xffe2 (Shift_R)
    113         0xffea (Alt_R)
shift       Shift_L (0x32),  Shift_R (0x3e)
mod1        Alt_L (0x40),  Alt_R (0x71)
$ xmodmap -e 'remove Mod1 = Alt_R' -e 'keycode 113 = Shift_R' -e 'add Shift =
Shift_R' -e 'keycode 9 = grave asciitilde' -e 'keycode 49 = Escape'
$ { xmodmap -pk; xmodmap -pm; } | fgrep -i 'Alt_R
> Shift_R
> mod1
> Escape
> asciitilde'
      9         0x0060 (grave)  0x007e (asciitilde)
     49         0xff1b (Escape)
     62         0xffe2 (Shift_R)
    113         0xffe2 (Shift_R)
shift       Shift_L (0x32),  Shift_R (0x3e),  Shift_R (0x71)
mod1        Alt_L (0x40)
$

I'm a vi user too.  As I hop among systems/keyboards semi-regularly,
I tend to use Control-[ and Control-h to respectively generate Escape
and Backspace, generally regardless of keyboard and where Escape and
Backspace may be placed on random keyboards (and what random keyboards
may generate when hitting the Backspace key).  Unfortunately, when the
printable ascii characters jump around on random keyboards, that's not
quite as simple to deal with (particularly if it's a serial terminal).

I guess at least part of my keyboard philosophy includes:
the erase character is backspace
the interrupt character is Control-C
the backspace key should generate backspace
the delete key (if present) should generate the ascii delete character
Control-Shift-/ (a.k.a. Control-?) on the keyboard should generate the
ascii delete character
CapsLock is and should be CapsLock, it's not CapsToggle! (i.e. if
CapsLock is active, the shift keys have essentially no effect) (some of
us are actually used to typing with mostly correct capitalization ... if
CapsLock is on, getting inverse capitalization tends to be quite
annoying and counter-productive).
... but that tends to get into religion ;-)

On my Debian GNU/Linux systems:
$ fgrep -i erase ~/.Xdefaults
XTerm*ttyModes:  erase ^H
$ ls -l /etc/*.d/*local*keymap*
-rwxr-xr-x    1 root     root         1507 Aug  1  2003 /etc/init.d/local-keymap.sh
lrwxrwxrwx    1 root     root           25 Jan 15  2004
/etc/rcS.d/S05local-keymap.sh -> ../init.d/local-keymap.sh
$ cat /etc/init.d/local-keymap.sh
#!/bin/sh

#
# Load local keymap modifications *as soon as possible*
#

test -f /bin/loadkeys || exit 0

case "$1" in
        start|restart|force-reload|reload)
                echo Loading local keymap modifications from $0

                echo '

                        #plain, Shift, AltGr; Control, Control+Shift,
Control+AltGr; Alt, Alt+Shift; Alt+Control
                        keymaps 0-2,4-6,8-9,12

                        alt_is_meta

                        #make the Backspace key generate BackSpace
                        keycode 14 = BackSpace


                        #make shifted letters generate uppercase regardless of
Caps Lock state
                        shift keycode 16 = Q
                        shift keycode 17 = W
                        shift keycode 18 = E
                        shift keycode 19 = R
                        shift keycode 20 = T
                        shift keycode 21 = Y
                        shift keycode 22 = U
                        shift keycode 23 = I
                        shift keycode 24 = O
                        shift keycode 25 = P
                        shift keycode 30 = A
                        shift keycode 31 = S  
                        shift keycode 32 = D
                        shift keycode 33 = F
                        shift keycode 34 = G
                        shift keycode 35 = H
                        shift keycode 36 = J  
                        shift keycode 37 = K
                        shift keycode 38 = L
                        shift keycode 44 = Z
                        shift keycode 45 = X
                        shift keycode 46 = C
                        shift keycode 47 = V
                        shift keycode 48 = B
                        shift keycode 49 = N
                        shift keycode 50 = M

                        #make control-shift-/ i.e. control-? generate Delete
                        shift control keycode 53 = Delete

                        #make the Delete key generate Delete
                        keycode 111 = Delete

                        #control-alt-delete --> Boot
                        altgr control keycode 111 = Boot
                        control alt keycode 111 = Boot

                ' |
                /bin/loadkeys
        ;;
        stop)
                :
        ;;
        *)
                echo "Usage: $0 {start|stop|restart|reload|force-reload}"
                exit 1
        ;;
esac



More information about the buug mailing list