Created
July 1, 2015 20:43
-
-
Save atdt/d634d00be9679ee0394e to your computer and use it in GitHub Desktop.
Temporarily disable MBP's internal keyboard, so I can clean it :)
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
#!/usr/bin/env bash | |
KEYBOARD_KEXT="/System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/" | |
countdown() { | |
local seconds="$1" | |
while [ $seconds -gt 0 ]; do | |
sleep 1 & | |
echo -n "${seconds}.. " | |
seconds=$(( $seconds - 1 )) | |
wait | |
done | |
echo | |
} | |
disable_keyboard() { | |
sudo kextunload "$KEYBOARD_KEXT" &>/dev/null | |
echo "Keyboard disabled." | |
} | |
enable_keyboard() { | |
sudo kextload "$KEYBOARD_KEXT" &>/dev/null | |
echo "Keyboard enabled." | |
} | |
# Get/extend sudo up-front for 5 minutes so it doesn't | |
# expire between the first and second command. | |
sudo -v | |
trap enable_keyboard EXIT | |
disable_keyboard | |
countdown 30 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment