Skip to content

Instantly share code, notes, and snippets.

  • Save victorliun/34e36a4021e28954048dc8f4ff06609c to your computer and use it in GitHub Desktop.
Save victorliun/34e36a4021e28954048dc8f4ff06609c to your computer and use it in GitHub Desktop.
The primary goal is to swap command and option.
The secondary goal is to remap Caps Lock to Control.
The tertiary goal is to share modifier keys across keyboards, so you can emacs with two keyboards.
The following instructions are good as of 2016-08-24, for OS X El Capitan 10.11.6.
Mac OS Sierra broke Seil support; Seil instructs us to consider Karabiner Elements.
But when Karabiner Elements swaps command and option, it does it for all keyboards;
meaning the native keyboard also gets its command and option swapped, which is bad!
So you can't achieve the secondary goal on Sierra, as of 2017-02-01.
Anyway, assuming you're on El Capitan, read on.
Ordinarily I would go into Keyboard Preferences, Modifier Keys; I would select the name of the external keyboard
and I would tell it to turn Command into Option, Option into Command, and Caps Lock into Control.
But the Varmilo VB87M Mechanical Bluetooth Tenkeyless doesn't show up as an external keyboard. Weird, right?
You can't just swap command and option globally or your local keyboard will be affected.
When I added it, I had to "add Bluetooth device" under Bluetooth preferences,
rather than "add Bluetooth keyboard" under Keyboard preferences.
It's almost annoying enough to make you give up and look for something else on the list of wireless mechanicals
https://www.reddit.com/r/MechanicalKeyboards/wiki/wireless-mechanical_keyboards
which has dip switches for this scenario, or is better recognized in Bluetooth.
But, like me, you got suckered into the Massdrop, and now you're stuck with it.
Well, it's not the end of the world. In the time it takes to eat a cookie, you'll be right as rain, said the Oracle!
In our case, in the time it takes to shave a yak.
Install Karabiner: https://pqrs.org/osx/karabiner/
Install Seil: https://pqrs.org/osx/karabiner/seil.html
If you're impatient, you can (kinda) get what you want by swapping command and option (you have to select
four separate option checkboxes) and then excluding the internal keyboard under core settings; but that defeats
the purpose of installing Karabiner in the first place, which was for me the ability to hit a modifier on one
keyboard and another key on another keyboard.
So here's how to do it right:
First make Caps Lock into Control. In System Preferences, set Caps Lock to No Action,
then tell Seil to change the Caps Lock key to keycode 59.
Then, in Karabiner Preferences, Misc & Uninstall, Open private.xml. That will reveal it in Finder.
Edit private.xml in an actual text editor and insert the below contents. Save. Then go to Change Key, Reload XML,
and it'll be the first menu option under Varmilo: swap command and option.
<?xml version="1.0"?>
<root>
<!-- ============================================================ -->
<!-- the varmilo needs to manually swap command and option -->
<!-- you're welcome! mengwong@pobox.com. 20160824 -->
<!-- No support available, figure it out yourself, sorry. -->
<!-- https://gist.github.com/mengwong/6cf35acdf4b5ccfe3cc6be2529da3296 -->
<devicevendordef>
<vendorname>VARMILO</vendorname>
<vendorid>0x1915</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>VB87MS</productname>
<productid>0xeeee</productid>
</deviceproductdef>
<item>
<name>Varmilo VB87MS</name>
<item>
<name>swap command and option</name>
<identifier>private.varmilo_swap</identifier>
<device_only>DeviceVendor::VARMILO, DeviceProduct::VB87MS</device_only>
<autogen>__KeyToKey__ KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen>
<autogen>__KeyToKey__ KeyCode::OPTION_L, KeyCode::COMMAND_L</autogen>
<autogen>__KeyToKey__ KeyCode::COMMAND_R, KeyCode::OPTION_R</autogen>
<autogen>__KeyToKey__ KeyCode::OPTION_R, KeyCode::COMMAND_R</autogen>
</item>
<!-- need https://pqrs.org/osx/karabiner/seil.html to do caps lock -->
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment