Restructured genkeymap/dump-keymaps.sh

This commit is contained in:
matt335672 2024-05-23 19:14:32 +01:00
parent 2be49f3d73
commit 7301b505c9

View File

@ -1,5 +1,33 @@
#!/bin/sh #!/bin/sh
# Use evdev rules to obtain the mappings
XKB_RULES=evdev
# -----------------------------------------------------------------------------
# K B G E N
#
# Generates a keyboard mapping
# $1 - LCID (See [MS-LCID])
# $2 - Language tag (See [MS-LCID])
# $3 - Current operating system
# $4.. Arguments to setxkbmap to select the required keyboard
# -----------------------------------------------------------------------------
kbgen()
{
file=$(printf "../instfiles/km-%08s.toml" "$1" | tr ' ' '0')
desc="$2"
os="$3"
shift 3
setxkbmap "$@"
./xrdp-genkeymap \
-c "Description: $desc" \
-c "Operating system: $os" \
"$file"
}
# -----------------------------------------------------------------------------
# M A I N
# -----------------------------------------------------------------------------
# Run the keymap extraction in a clean X session # Run the keymap extraction in a clean X session
if [ "$1" != _IN_XVFB_SESSION_ ]; then if [ "$1" != _IN_XVFB_SESSION_ ]; then
# All commands available? # All commands available?
@ -15,59 +43,57 @@ if [ "$1" != _IN_XVFB_SESSION_ ]; then
exit 1 exit 1
fi fi
xvfb-run --auto-servernum --server-args="-noreset" $0 _IN_XVFB_SESSION_ xvfb-run --auto-servernum --server-args="-noreset" "$0" _IN_XVFB_SESSION_
exit $? exit $?
fi fi
OLD_SETTINGS=$(setxkbmap -query -verbose 4 | sed "s/^\([a-z]\+\):\s*\(.*\)$/-\1 \2/;s/^-options/-option \"\" -option/;s/,/ -option /g" | xargs -d \\n) OLD_SETTINGS=$(setxkbmap -query -verbose 4 | sed "s/^\([a-z]\+\):\s*\(.*\)$/-\1 \2/;s/^-options/-option \"\" -option/;s/,/ -option /g" | xargs -d \\n)
# Use evdev rules for these mappings setxkbmap -rules "$XKB_RULES"
setxkbmap -rules evdev
# English - US 'en-us' 0x00000409 # Assign NumLock to mod2
setxkbmap -model pc104 -layout us xmodmap -e "clear mod2" -e "add mod2 = Num_Lock"
./xrdp-genkeymap ../instfiles/km-00000409.ini
# English - US 'dvorak' 0x00010409 # Find the operating system
setxkbmap -model pc104 -layout dvorak if command -v hostnamectl >/dev/null; then
./xrdp-genkeymap ../instfiles/km-00010409.ini os=$(hostnamectl status | sed -ne 's/^i *Operating[^:]*: *//p')
fi
if [ -z "$os" ] && command -v lsb_release -v >/dev/null; then
os=$(lsb_release --description --short)
fi
if [ -z "$os" ]; then
os="Unknown"
fi
# English - US 'dvp' 0x19360409 kbgen 0406 "da-DK" "$os" -model pc105 -layout dk
setxkbmap -rules xfree86 -model pc105 -layout us -variant dvp -option "" -option compose:102 -option caps:shift -option numpad:sg -option numpad:shift3 -option keypad:hex -option keypad:atm -option kpdl:semi -option lv3:ralt_alt kbgen 0407 "de-DE" "$os" -model pc104 -layout de
./xrdp-genkeymap ../instfiles/km-19360409.ini kbgen 0409 "en-US" "$os" -model pc104 -layout us
setxkbmap ${OLD_SETTINGS} kbgen 10409 "en-US" "$os" -model pc104 -layout dvorak
kbgen 040a "es-ES_tradnl" "$os" -model pc105 -layout es
# English - UK 'en-GB' 0x00000809 kbgen 040b "fi-FI" "$os" -model pc105 -layout 'fi'
setxkbmap -model pc105 -layout gb kbgen 040c "fr-FR" "$os" -model pc105 -layout fr
./xrdp-genkeymap ../instfiles/km-00000809.ini kbgen 0410 "it-IT" "$os" -model pc104 -layout it
kbgen 0411 "ja-JP" "$os" -model pc105 -layout jp -variant OADG109A
# German 'de' 0x00000407 kbgen 0412 "ko-KR" "$os" -model pc105 -layout kr
setxkbmap -model pc104 -layout de kbgen 0414 "nb-NO" "$os" -model pc105 -layout no
./xrdp-genkeymap ../instfiles/km-00000407.ini kbgen 0415 "pl-PL" "$os" -model pc104 -layout pl
kbgen 0416 "pt-BR" "$os" -model pc105 -layout br
# Italian 'it' 0x00000410 kbgen 0419 "ru-RU" "$os" -model pc104 -layout ru
setxkbmap -model pc104 -layout it kbgen 041d "sv-SE" "$os" -model pc104 -layout se
./xrdp-genkeymap ../instfiles/km-00000410.ini kbgen 0807 "de-CH" "$os" -model pc105 -layout ch
kbgen 0809 "en-GB" "$os" -model pc105 -layout gb
# Japanese 'jp' 0x00000411 kbgen 080a "es-MX" "$os" -model pc105 -layout latam
setxkbmap -model pc105 -layout jp -variant OADG109A kbgen 080c "fr-BE" "$os" -model pc105 -layout be -variant oss
./xrdp-genkeymap ../instfiles/km-00000411.ini kbgen 0813 "nl-BE" "$os" -model pc105 -layout be
kbgen 0816 "pt-PT" "$os" -model pc104 -layout pt
# Polish 'pl' 0x00000415 kbgen 100c "fr-CH" "$os" -model pc105 -layout ch -variant fr
setxkbmap -model pc104 -layout pl
./xrdp-genkeymap ../instfiles/km-00000415.ini
# Russia 'ru' 0x00000419
setxkbmap -model pc104 -layout ru
./xrdp-genkeymap ../instfiles/km-00000419.ini
# Sweden 'se' 0x0000041d
setxkbmap -model pc104 -layout se
./xrdp-genkeymap ../instfiles/km-0000041d.ini
# Portuguese -PT 'pt-pt' 0x00000816
setxkbmap -model pc104 -layout pt
./xrdp-genkeymap ../instfiles/km-00000816.ini
# Put keyboards which change options below the ones that don't to
# prevent unexpected things happening to keypads, etc
kbgen 19360409 "en-US" "$os" -model pc105 -layout us -variant dvp \
-option "" -option compose:102 -option caps:shift -option numpad:sg \
-option numpad:shift3 -option keypad:hex -option keypad:atm \
-option kpdl:semi -option lv3:ralt_alt
# set back to entry settings # set back to entry settings
# shellcheck disable=SC2086
setxkbmap ${OLD_SETTINGS} setxkbmap ${OLD_SETTINGS}