dotool/xkeys.bash

43 lines
1.3 KiB
Bash
Raw Normal View History

2022-10-20 15:21:20 +02:00
#!/bin/bash
align() {
sed '/\<KeyRo\>/ d
/\<KeyKpjpcomma\>/ d
/\<KeyMacro\>/ d
/\<KeyYen\>/ d
/\<KeySetup\>/ d
/\<KeyDeletefile\>/ d
/\<KeyClosecd\>/ d
/\<KeyEjectclosecd\>/ d
/\<KeyIso\>/ d
/\<KeyMove\>/ d
/\<KeyEdit\>/ d
/\<KeyAlterase\>/ d
/\<KeyUnknown\>/ d
/\<KeyMicmute\>/ d'
}
2023-01-26 13:47:10 +01:00
normal="$({
2022-10-20 15:21:20 +02:00
paste -d ' ' <(xmodmap -pke | sed '1 d; s/.*= /"/; /.*=/ d; s/ .*/":/' | sed '/^"XF86Eject"/ { N; s/.*\n// }') \
<(go doc uinput.keyesc | sed '/Key/ !d; s/^\s*/uinput./; s/ .*/,/' | align) |
# Skip really non-matching section, we echo some of them below
sed '/^"XF86Tools"/,/^"XF86AudioPreset"/ d' |
# Remove duplicate keys
2023-01-26 13:47:10 +01:00
sed '/^"XF86Mail":.*Email/ d; /^"Cancel":.*Stop/ d; /^"XF86Send":.*file/ d; /^"Print":.*Sysrq/ d; /Key102Nd,$/ d'
2022-10-20 15:21:20 +02:00
echo '"XF86WebCam": uinput.KeyCamera,'
echo '"Print": uinput.KeyPrint,'
2023-01-26 13:47:10 +01:00
} | sed 's/^".*"/\L&/; s/^/\t/')"
printf %s\\n "var xKeysNormal = map[string]int{
$normal
}
"
2022-10-20 15:21:20 +02:00
echo 'var xKeysShifted = map[string]int{'
{
paste -d ' ' <(xmodmap -pke | sed '1 d; s/.*= /"/; /.*=/ d; s/\S* /"/; s/ .*/":/' | sed '/^"XF86Eject"/ { N; s/.*\n// }') \
2023-01-26 13:47:10 +01:00
<(go doc uinput.keyesc | sed '/Key/ !d; s/^\s*/uinput./; s/ .*/,/' | align) | sed '/^"NoSymbol"/ d; /^\S*_[LR]"/ d; /Key102Nd,$/ d'
} | sed 's/^".*"/\L&/; s/^/\t/' | awk 'NR == FNR {if (length($1) > 4) a[$1]; next} !($1 in a)' <(printf %s\\n "$normal") -
2022-10-20 15:21:20 +02:00
echo '}'