Last active
July 1, 2017 11:39
-
-
Save lulu-berlin/637f162ddeaf8af3007083b8ca8adf8a to your computer and use it in GitHub Desktop.
How to fix numeric keypad on Linux not working with java applications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# credit to Peter L on StackOverflow: | |
# https://stackoverflow.com/questions/32753190/how-to-get-numeric-keypad-arrows-working-with-java-applications-on-linux/32753332#32753332 | |
#!/bin/bash | |
SYMBOLS="/usr/share/X11/xkb/symbols" | |
KEYPAD="$SYMBOLS/keypad" | |
# create a backup in a temporary directory | |
TMP=$(mktemp -d) | |
cp "$KEYPAD" "$TMP/keypad" | |
# make a numbered backup in the original directory | |
sudo cp --backup=numbered "$TMP/keypad" "$SYMBOLS" | |
# fix the keypad file into the temporary directory | |
KEYS=("Up" "Down" "Left" "Right" "Home" "End" "Prior" "Next") | |
REGEX="s/KP_\("${KEYS[0]}$(printf "\|%s" "${KEYS[@]:1}")"\)/\1/g" | |
sed -e "$REGEX" "$KEYPAD" > "$TMP/keypad" | |
# overwrite the original keypad file | |
sudo cp "$TMP/keypad" "$KEYPAD" | |
# delete the temporary directory | |
rm -rf "$TMP" | |
# update the xkb symbols | |
sudo dpkg-reconfigure xkb-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment