Last active
December 14, 2019 05:43
-
-
Save cympfh/1dafa0e1347f2607c42ad900782c994d to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| BUILTIN_KBD_NAME="AT Translated Set 2 keyboard" | |
| BLUETOOTH_KBD_NAME="HHKB-Hybrid_" | |
| xinput set-prop "$BUILTIN_KBD_NAME" "Device Enabled" 1 | |
| trap "xinput set-prop '$BUILTIN_KBD_NAME' 'Device Enabled' 1; exit" 2 | |
| STATUS=none | |
| while :; do | |
| if bluetoothctl info | grep "$BLUETOOTH_KBD_NAME" >/dev/null; then | |
| NEW_STATUS=1 # BT kbd is available | |
| else | |
| NEW_STATUS=0 | |
| fi | |
| if [ "$STATUS" != "$NEW_STATUS" ]; then | |
| STATUS="$NEW_STATUS" | |
| if [ "$STATUS" = 1 ]; then | |
| echo "BT kbd is available. Disable the builtin kbd" | |
| xinput set-prop "$BUILTIN_KBD_NAME" "Device Enabled" 0 | |
| else | |
| echo "BT kbd is not available. Enable the builtin kbd" | |
| xinput set-prop "$BUILTIN_KBD_NAME" "Device Enabled" 1 | |
| fi | |
| fi | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment