Created
March 1, 2015 01:59
-
-
Save draplater/2bc4f8ba41cf49fb2d8c to your computer and use it in GitHub Desktop.
switch keyboard state
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/sh | |
#if ! xinput | grep -q "Poker II"; then | |
if ! lsusb -v 2> /dev/null | grep -q Keyboard; then | |
echo "No external keyboard" | |
exit 1 | |
fi | |
keyboard_id=$(xinput | grep "AT Translated Set 2 keyboard" | grep -Po "(?<=id=)\d+") | |
if xinput | grep "AT Translated Set 2 keyboard" | grep -q "slave keyboard"; then | |
xinput float $keyboard_id | |
echo "Keyboard floated." | |
else | |
master_id=$(xinput | grep "master keyboard" | grep -Po "(?<=id=)\d+") | |
xinput reattach $keyboard_id $master_id | |
echo "Keyboard attached." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment