-
-
Save arthur-mts/f0b195e5773d1d288a99cd2d69b19e6e to your computer and use it in GitHub Desktop.
keyboard_detect.sh
This file contains 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
#!/bin/bash | |
devices=$(lsusb) | |
command="" | |
while IFS= read -r line; do | |
if grep -q "Logitech, Inc. Logi TKL Mechanical Keyboard" <<< "$line"; then | |
#echo "$line" | |
#echo "There is a Logitch keyboard" | |
## Set the desired keymap | |
command="setxkbmap -model pc105 -layout us -variant intl" | |
fi | |
done <<< "$devices" | |
if [ "$command" == "" ]; then | |
command='setxkbmap -model pc105 -layout br -variant abnt2' | |
if ! command -v setxkbmap &> /dev/null; then | |
echo "setxkbmap not found. Please make sure it's installed." | |
exit 1 | |
fi | |
eval "$command" | |
else | |
echo $'keycode 48 = apostrophe quotedbl apostrophe quotedbl dead_acute diaeresis\nkeycode 54 = c C c C ccedilla Ccedilla' > .Xmodmap | |
if ! command -v setxkbmap &> /dev/null; then | |
echo "setxkbmap not found. Please make sure it's installed." | |
exit 1 | |
fi | |
eval "$command" | |
xmodmap ~/.Xmodmap | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment