There was a blunder in the previous script: redirection not in the right
place.

Please find below the corrected version:

-----8<----
#!/bin/sh
# C) 2020 Thierry Laronde <tlaro...@polynum.com>
# Public Domain.
# No warranty! Use at your own risk!

: ${TMPDIR:=/tmp}

cat <<EOT >&2
When the window will appear, click first in the xterm
and then in the window (the square in the blank window).

You can then start to press Meta keys: "Windows",
Alt, AltGr, arrows, home, end, page up, page down...
so that we can generate the xmodmap rules.

Press any key to start. Kill the xev window when done.
EOT
read ans

# Get keycode keysym name from xev.
#
xev -event keyboard 2>&1\
        | sed -n -e 's/^Outer window is \(0x[^,]*\).*$/\1/p' \
                -e 's/^.*keycode \([0-9][0-9]*\) (keysym 
0x\([a-f0-9][a-f0-9]*\), \([^)][^)]*\)).*$/\1 \2 \3/p'\
        | sort | uniq\
        | while read keycode keysym name; do
                test "$keysym" || { wid=$keycode; continue; } # unused
                echo "keycode $keycode = $name"
                case $name in
                        Shift_[LR]) echo "add shift = $name";;
                        Control_[LR]) echo "add control = $name";;
                        Alt_L|Meta_L) echo "add mod1 = $name";;
                        Super_[LR]|Hyper_L) echo "add mod4 = $name";;
                        ISO_Level3_Shift|Mode_switch) echo "add mod5 = $name";;
                esac
        done >$TMPDIR/xmodmap

xmodmap $TMPDIR/xmodmap
---->8-----
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

Reply via email to