Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mengwong/6cf35acdf4b5ccfe3cc6be2529da3296 to your computer and use it in GitHub Desktop.
Save mengwong/6cf35acdf4b5ccfe3cc6be2529da3296 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>
@deltaepsilon
Copy link

I think you just saved my morning. THANK YOU!!!!

@antoinefortin
Copy link

Thanks a lot, this post saved me a lot of time.

@lailoken
Copy link

lailoken commented Oct 5, 2018

Or you can just go to System Preferences -> Keyboard -> Modifier Keys

And swap them there?

@marnovo
Copy link

marnovo commented Feb 8, 2019

This sheet might be useful. Often it's a pain to remap keycaps/hardware/software/target:
https://docs.google.com/spreadsheets/d/1BxNFdZbKnkhOkbsBINugxJpULkWD8jCH8h1VXGkz-9M/edit?usp=sharing

@Shad0wLi0n
Copy link

Shad0wLi0n commented Mar 6, 2019

For Mojave 10.14.1, Karabiner has been updated and now recognizes the Varmilo keyboard without needing to modify the XML file. You can easily remap the keys without touching the built in keyboard settings. You also do not need Seil anymore all the functionality has been added to the updated Karabiner app.

@atallaramy
Copy link

atallaramy commented Aug 6, 2020

Or you can just go to System Preferences -> Keyboard -> Modifier Keys

And swap them there?

I think the problem is that you have to specify which keboard is being modified other wise it could be confusing a bit as I had it in the start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment