If I enable Karabiner-Elements for my external keyboard, then my settings in "System Preferences" → "Keyboard" → "Modifier Keys" no longer have any effect.
For example, most PC keyboards need Command (Windows key) and Alt swapped in order to behave like an Apple keyboard, i.e. in order to have Command next to the spacebar. This prevents that — I would have to swap them in K-E directly, which would mean that my Macbook internal keyboard would be broken until I un-swapped them.
The result is that I have to choose between breaking Command & Alt on my external keyboard, breaking them on my internal keyboard, or just turning off K-E for my external keyboard and losing all my other K-E keys.
😢
Here's the way I work around this, I create two profiles with only the modifier keys changed. I then use hammerspoon and a bash script to swap between them when the keyboard is unplugged. Here's the relevant section of my hammerspoon config:
hs.usb.watcher.new(
function(usbDetails)
if usbDetails.productID == 8211 then
if usbDetails.eventType == "added" then
local output = os.execute("/Users/michael/.karabiner.d/swapper.sh added")
else
local output = os.execute("/Users/michael/.karabiner.d/swapper.sh removed")
end
end
end
):start()
You'd have to change the path to the bash script and the the product id of your keyboard (8211 in the script above). You can figure out the product id of your keyboard by opening up hammerspoon's console and running:
for index, usb_device in pairs(hs.usb.attachedDevices()) do
print(hs.inspect(usb_device))
end
then I use this script to swap between them:
#! /bin/bash
KARABINER=/Users/michael/.karabiner.d/configuration/
if [[ $1 == 'added' ]]; then
rm -f $KARABINER"karabiner.json"
cp $KARABINER"karabiner.json.das" $KARABINER"karabiner.json"
fi
if [[ $1 == 'removed' ]]; then
rm -f $KARABINER"karabiner.json"
cp $KARABINER"karabiner.json.apple" $KARABINER"karabiner.json"
fi
Just wanted to note that if #592 gets implemented, it will provide a workaround for this problem. That said, it may still be worth solving this problem at some point.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.