Skip to content

Instantly share code, notes, and snippets.

@smileart
Last active December 25, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save smileart/6990307 to your computer and use it in GitHub Desktop.
Save smileart/6990307 to your computer and use it in GitHub Desktop.
Little shell script to manage (enable/disable) keyboard on Mac WARNING! To enable keyboard, use Keyboard Viewer from keyboard layout menu
# Add ’alias key='~/key.sh'’ to .bashrc or .zshrc
case "$1" in
"off") sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ > /dev/null 2>&1
echo "Keyboard is temporary disabled"
;;
"on") sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ > /dev/null 2>&1
echo "Keyboard is enabled again"
;;
"easy") sudo -K
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ > /dev/null 2>&1
echo "Keyboard is temporary disabled. Press ’any key’ ;) to enable"
read -n 1 -s
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ > /dev/null 2>&1
sudo -k
echo "Keyboard is enabled again"
;;
*) echo "Use 'on'/'off' or 'easy' commands!"
;;
esac
sudo -k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment