jasonrudolph / keyboard

⌨ Toward a more useful keyboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removing Karabiner-Elements as a dependency

steeef opened this issue · comments

The next major release of macOS, Big Sur, removes kernel extensions, and in doing so, breaks Karabiner-Elements' functionality (pqrs-org/Karabiner-Elements#2331). There does appear to be a replacement in the works (https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice), but I'd like to figure out if it's possible to just stick with Hammerspoon to do all the complex mapping.

You can use Mac's built-in hidutil to do simple mapping (e.g., Left Control to F19 for use as a "Hyper" key):
https://developer.apple.com/library/archive/technotes/tn2450/_index.html#//apple_ref/doc/uid/DTS40017618-CH1-KEY_TABLE_USAGES

Using hidutil to remap keys, I was able to get your "control-escape" button with Caps Lock mapped to Left Control, as well as use it to remap Left Control to F19 and then use F19 as my "Hyper" key.

I've got a few other Karabiner mappings I'd like to recreate with the hidutil/Hammerspoon combo, but I'm a bit out of my depth here. Being able to map modifiers to different keys if they're held or pressed (like your Super-Duper key combo, for example) would be sweet, I just need to figure out how to generalize it in Lua for Hammerspoon.

Any thoughts?

👋 @steeef: It's possible to entirely remove the dependency on Karabiner-Elements, but in my experience, doing so has always involved some UX compromises.

Back in 2018, pqrs-org/Karabiner-Elements#545 led me to remove the dependency on Karabiner-Elements and implement everything with Hammerspoon, and I shipped that change in jasonrudolph/keyboard v4.0.0.

That worked, but I found the UX of that particular implementation to be inferior as described in #38. (Perhaps there's an alternative Hammerspoon-based implementation that would provide UX comparable to the Karabiner-Elements implementation, but I'm not aware of such an implementation.) So once pqrs-org/Karabiner-Elements#545 was resolved, #38 reinstated the use of Karabiner-Elements.

The problems described in #40, #59, and #60 were also side effects of removing the dependency on Karabiner-Elements. #61 resolved those issues by porting (S)uper (D)uper Mode from Hammerspoon to Karabiner-Elements.

With that in mind, I will likely postpone my personal upgrade to Big Sur until https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice is capable of supporting all the existing functionality in this repository.

I hope that helps.

Thanks for the explanation. After spending some time tweaking Hammerspoon settings, I've noticed similar UX issues. I think I'm stuck with Karabiner-Elements for now as well.