#!/bin/bash | |
# Unload the keyboard so I can use my external keyboard | |
# and not worry about accidentally pressing buttons on | |
# the built-in. This may not be a problem for you but, you | |
# should see my desk sometimes (Oh no!!) ;-) | |
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ |
sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
(apparently! http://hintsforums.macworld.com/showpost.php?s=3c2007699e473182d749410f2fceb2aa&p=670405&postcount=10 )
Does this still work for you on OS X Mavericks 10.9.1? It used to work for me before, but now I'm getting:
(kernel) Can't unload kext com.apple.driver.AppleUSBTCKeyboard; classes have instances:
(kernel) Kext com.apple.driver.AppleUSBTCKeyboard class AppleUSBTCKeyboard has 1 instance.
Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) kext is in use or retained (cannot unload).
I can' too
mine 10.9.5
Despite the error, the internal keyboard seems disabled after the command.
os version 10.9.5
I get the same error, but my keyboard is still enabled. OSX 10.10.2. Below is what the error says. Any help is appreciated.
(kernel) Kext com.apple.driver.AppleUSBTCKeyboard not found for unload request.
Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) not found.
Great work. Even though I still get the error, it works beautifully. Thank you. Is there a way to make a button out of this snippet? I use this at least once a day since my built-in keyboard has a mysterious shortage.
for the ones looking for a way to disable the internal keyboard because you have a external one attached you can use this https://pqrs.org/osx/karabiner/gallery.html.en#disable-built-in-keyboard-if-external-keyboard-exists
also i tested the code about on OSX 10.11 and the unload works but i cannot load the kernel extension back and it only works if I reboot my computer
@arthurnn: Kudos to you!
@arthurnn: awesome!
WARNING:
Running this code on 10.11.3 crashed my mac. Just turned off and gave me the "something went wrong with your mac error" before restarting twice, and turning back on fine (with they keyboard enabled)
Looks like this solution doesn't work anymore.
It used to work for me on Sierra. After I upgraded my OS to catalina, It stopped working. It gives me this error.
(kernel) Can't remove kext com.apple.driver.AppleUSBTCKeyboard; services failed to terminate - 0xe00002c7.
Failed to unload com.apple.driver.AppleUSBTCKeyboard - (iokit/common) unsupported function.
I'm getting the same error as @rahul1990gupta
Im avin te same issue, did anyone ind a soution to tis
- Unload native keyboard:
sudo kextunload -v 5 /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
- Reload native keyboard:
sudo kextload -v 5 /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/
This does work on new versions of MacOS, but only when System Integrity Protection (SIP) is not affecting the context. SIP was introduced in El Capitan and got some upgrades in Mojave, so all newer MacOS will have this enabled: csrutil status
- On El Capitan, Sierra and High Sierra, the kernel extension changes will throw an error due to some perms being protected, but the keyboard disabling does work
- On Mojave, Catalina, Big Sur (and beyond), SIP protections won't even let a sudoer see
com.apple.driver.AppleUSBTCKeyboard
, so thekextload
finds nothing to unload
if you're on Mojave and above, running csrutil disable
would "fix" the issue, but there are three caveats:
- SIP can't be disabled from the active OS instance itself, so the easiest solution is to boot from the recovery partition (
cmd
+r
on boot) and runcsrutil disable
from there - You must re-enable (via
kextload
) your built-in keyboard, or use a non-bluetooth keyboard, if you want to enter recovery mode at a later date, after disabling your keyboard withkextunload
- You are disabling MacOS's native protections for system-level directories, which technically would allow a 3rd party service to inject malicious code in a number of ways. Technically the app would need
sudo
permissions first to do that though. This is easy enough to protect and manage on a *nix server somewhere because you (should) have protections in place and a strict policy on who cansu
orsudo
and when. But on an os with a GUI, with applications being closed, opened, installed, etc. constantly, it's not so easy to ensure something doesn't slip in.
TBD:
- Is there a way to limit SIP's strictness without reboot/recovery (like
selinux
config)? The answer is a soft "no" per the official docs. But there is an interesting output ofSystem Integrity Protection status: enabled (Custom Configuration)
. This could suggest that it may be possible to selectively disable SIP features and set a custom config, but no suggestion on how this could be done is exposed in the docs. If someone knows more about this, lmk (/usr/bin/csrutil
is a binary inmach-o
format by the way) - How do 3rd parties like Karabiner-Elements accomplish disabling the keyboard? Perhaps they don't even need to touch the kernel extensions. It was implemented in this issue,
v0.90.63
, but I can't find a release with that tag so I don't see the commit. Searching through the codebase doesn't show anything too obvious re: kext. Any insight on that would be helpful too.
How to reload the kb?
sude kextload ?