Skip to content

Instantly share code, notes, and snippets.

@Mnkai
Created March 14, 2018 14:26
Show Gist options
  • Save Mnkai/a43f7c0680633204856cde56961b6dcd to your computer and use it in GitHub Desktop.
Save Mnkai/a43f7c0680633204856cde56961b6dcd to your computer and use it in GitHub Desktop.
Toggle keyboard device - useful if you are using external keyboard on your laptop's keyboard
#!/bin/sh
# 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
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment