Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Last active June 5, 2020 06:37
Show Gist options
  • Save bjeanes/1ce8aed3feeccd145a80 to your computer and use it in GitHub Desktop.
Save bjeanes/1ce8aed3feeccd145a80 to your computer and use it in GitHub Desktop.
Using a Yubikey on OS X in non-QWERTY layouts

Using a Yubikey on OS X in non-QWERTY layouts

Using Karabiner This uses Karabiner (previously called KeyRemap4Macbook) to re-map just the Yubikey device back to QWERTY at the OS-level, but only when you aren't already using QWERTY!

Instructions

  1. Install Karabiner.
  2. Replace (or amend) your private.xml file with the contents of the other file in this Gist
  3. Press "Reload XML"

Et voilà!

For Dvorak

I didn't fill in the reverse mappings, but Karabiner already includes a "Use Dvorak (No Yubikeys)" option if you are happy to let Karabiner do the Dvorak remapping. Otherwise, copy what I did for Colemak to "undo" the system-level Dvorak mapping.

<?xml version="1.0"?>
<root>
<!-- TODO: Add to https://github.com/tekezo/Karabiner/blob/master/src/core/server/Resources/inputsourcedef.xml -->
<!-- (Dvorak is already defined in Karabiner) -->
<inputsourcedef>
<name>COLEMAK</name>
<inputsourceid_prefix>com.apple.keylayout.Colemak</inputsourceid_prefix>
</inputsourcedef>
<item>
<name>Yubikey from Colemak to QWERTY</name>
<identifier>private.yubikey_colemak_qwerty</identifier>
<device_only>DeviceVendor::YUBICO</device_only>
<inputsource_only>COLEMAK</inputsource_only>
<autogen>__KeyToKey__ KeyCode::F, KeyCode::E</autogen>
<autogen>__KeyToKey__ KeyCode::P, KeyCode::R</autogen>
<autogen>__KeyToKey__ KeyCode::G, KeyCode::T</autogen>
<autogen>__KeyToKey__ KeyCode::J, KeyCode::Y</autogen>
<autogen>__KeyToKey__ KeyCode::L, KeyCode::U</autogen>
<autogen>__KeyToKey__ KeyCode::U, KeyCode::I</autogen>
<autogen>__KeyToKey__ KeyCode::Y, KeyCode::O</autogen>
<autogen>__KeyToKey__ KeyCode::SEMICOLON, KeyCode::P</autogen>
<autogen>__KeyToKey__ KeyCode::R, KeyCode::S</autogen>
<autogen>__KeyToKey__ KeyCode::S, KeyCode::D</autogen>
<autogen>__KeyToKey__ KeyCode::T, KeyCode::F</autogen>
<autogen>__KeyToKey__ KeyCode::D, KeyCode::G</autogen>
<autogen>__KeyToKey__ KeyCode::N, KeyCode::J</autogen>
<autogen>__KeyToKey__ KeyCode::E, KeyCode::K</autogen>
<autogen>__KeyToKey__ KeyCode::I, KeyCode::L</autogen>
<autogen>__KeyToKey__ KeyCode::O, KeyCode::SEMICOLON</autogen>
<autogen>__KeyToKey__ KeyCode::K, KeyCode::N</autogen>
</item>
<!-- or use option defined https://github.com/tekezo/Karabiner/blob/master/src/core/server/Resources/include/checkbox/for_dvorak_users.xml#L95-L102 -->
<item>
<name>Yubikey from Dvorak to QWERTY</name>
<identifier>private.yubikey_dvorak_qwerty</identifier>
<device_only>DeviceVendor::YUBICO</device_only>
<inputsource_only>DVORAK</inputsource_only>
<!-- TODO -->
</item>
</root>
@kostaskriaridis
Copy link

Hello, thank you for this post.

But, I can't make it work. I installed karabiner, replaced private.xml with content you've written and pressed Reload XML.
But my yubikey still doesn't work. What did i do wrong?

@bjeanes
Copy link
Author

bjeanes commented Jun 5, 2020

@smike16 sorry Gists didn't have any kind of comment notification back when you made this comment. I don't use Yubikeys anymore so I can't say for sure, but my guess would be you have a different physical device than I had and the device identifiers might be different.

@kostaskriaridis
Copy link

@bjeanes, thank you for your reply. I just use qwerty layout for youbikey and kinda used to it already = )

@bjeanes
Copy link
Author

bjeanes commented Jun 5, 2020

cool!

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