pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.59k stars 835 forks source link

Disable internal keyboard #95

Closed p-a closed 7 years ago

p-a commented 7 years ago

Old Karabiner handled this very well, I would very much like to se this feature in Karabiner-Elements as well.

fengmiaosen commented 7 years ago

+1

cool4zbl commented 7 years ago

+1. A VERY useful & necessary feature while using a USB or bluetooth keyboard ! BTW, is there any json configurations to achieve this feature ?

Hezion commented 7 years ago

+1

alexleekt commented 7 years ago

+1

AndrewNatoli commented 7 years ago

Was this for disabling the internal keyboard entirely or disabling modifying the internal keyboard? i.e. when you unplug your external keyboard on a Macbook and go back to using the internal keyboard, the modifier keys won't affect it.

That bit was wonderful.

yetsun commented 7 years ago

+1

ohcrider commented 7 years ago

+1, my cat love sitting on internal keyboards😒

edgeterm commented 7 years ago

+1, I'd love to put my keyboard on my internal keyboards to save the space

nmqanh commented 7 years ago

+1, I also put my keyboard on my internal keyboard :), this feature is really essential.

leocg commented 7 years ago

This is Karabiner's major feature for me. I found a workaround to manually disable and enable internal keyboard for now:

Disable: sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

Enable: sudo kextload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext

When disabled, the following error returns, but the keyboard stops anyway:

(kernel) Can't unload kext com.apple.driver.AppleUSBTCKeyboard; classes have instances: (kernel) Kext com.apple.driver.AppleUSBTCKeyboard class AppleUSBTCKeyboard has 2 instances. Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) kext is in use or retained (cannot unload).

When re-enabled, the last 9 keystrokes pressed on internal keyboard while deactivated will be shown on active window.

2Y2s1mple commented 7 years ago

This command doesn't work on MacOS Sierra.

sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext (kernel) Kext com.apple.driver.AppleUSBTCKeyboard not found for unload request. Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) not found.

leocg commented 7 years ago

Check if System Integrity Protection (rootless) is disabled with:

csrutil status

Since 10.11 we have to disable it in order to modify files on /System, /sbin and /usr (excluding /usr/local).

Instructions about feature and how to enable/disable can be found at osxdaily's article.

yerffejytnac commented 7 years ago

@leocg — I have disabled SIP and ensured it's not enabled withcsrutil status, and was able to run your command to unload kext for keyboard, but can still type via the onboard keyboard. I have a HHKB that I like to rest on top of the internal keyboard and was hoping your solution would work, but I didn't have any luck. 👎

leocg commented 7 years ago

@cantyjeffrey I have a Pok3r keyboard and I use just like you, on top of the internal keyboard. Can you paste the error? I'm using 10.12, maybe it's an issue with 10.12.1.

cool4zbl commented 7 years ago

@leocg Hey there, I also have a Pok3r. But I run your workaround in 10.12 and 10.12.1, it returned me the same info:

$ sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext
Password:
(kernel) Kext com.apple.driver.AppleUSBTCKeyboard not found for unload request.
Failed to unload com.apple.driver.AppleUSBTCKeyboard - (libkern/kext) not found.

And I'm sure that

$ csrutil status
System Integrity Protection status: disabled.
leocg commented 7 years ago

@cool4zbl

hey there, you're not the only one getting the error. I was reading about it and found out that the kext isn't loaded into the system when you try to unload it.

Here are some steps you can follow:

1 - Run kextstat and look for something like: 190 0 0xffffff7f84230000 0x3000 0x3000 com.apple.driver.AppleUSBTCKeyboard (251) 95C8342E-C0CE-3E61-A790-E7D088E2C478 <86 20 18 15 7 6 5 4 3 1>

2 - Restart the computer if you cannot find it and run kextstat again after reboot. Verify if com.apple.driver.AppleUSBTCKeyboard is present this time

3 - run the kextunload command.

If the error keep showing, verify if the kext exists in you Mac by typing ls /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/. My MacBook Pro 17 (Late 2011) return 4 files:

If the file exists and you still can't unload it, paste the results of the commands below so I can compare to mine:

ls -lR /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/

and

find /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext/ -type f -exec md5 '{}' \;

nmqanh commented 7 years ago

Hello everyone, I wrote a Node.js script to automatically disable internal keyboard when external keyboard connected and vice versa. It work directly with Karabiner-Elements without any hacking with mac using csrutil disable.

You can feel free to use my script here, I wrote a guide in README also: https://github.com/nmqanh/karabiner-elements-disable-internal-when-external-connected

tekezo commented 7 years ago

I've added this function in v0.90.63. Please upgrade the latest version and configure in Devices tab.

161106-0002

ycjcl868 commented 5 years ago

How to turn on