Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Toggle keyboard device - useful if you are using external keyboard on your laptop's keyboard
# Change keyboard device name to your own - e.g., xinput list
KEYBOARD_DEV_NAME="AT Translated Set 2 keyboard"
KEYBOARD_DEV_ID=$(xinput list | grep "$KEYBOARD_DEV_NAME" | cut -f 2 | cut -d "=" -f 2)
KEYBOARD_ISENABLED=$(xinput list-props $KEYBOARD_DEV_ID | grep "Device Enabled" | cut -d ":" -f 2)
if [ $KEYBOARD_ISENABLED -eq 1 ]; then
xinput disable $KEYBOARD_DEV_ID
elif [ $KEYBOARD_ISENABLED -eq 0 ]; then
xinput enable $KEYBOARD_DEV_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment