pattulus
8/27/2015 - 6:26 PM

My `private.xml` for Karabiner (https://pqrs.org/osx/karabiner/index.html.en).

My private.xml for Karabiner (https://pqrs.org/osx/karabiner/index.html.en).

<?xml version="1.0"?>
<root>
    <item>
        <name>My Custom Keys</name>
        <!-- Caps Lock = Hyper is setup via Seil -->
        <item>
            <name>F19 to F19</name>
            <appendix>F19 to Hyper (ctrl+shift+cmd+opt)</appendix>
            <appendix>(+ F19 Only, send escape)</appendix>
            <identifier>private.f19-to-f19-and-escape</identifier>
            <autogen>
                --KeyOverlaidModifier--
                KeyCode::F19,
                KeyCode::COMMAND_L,
                ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
                KeyCode::ESCAPE
            </autogen>
        </item>
        <!-- Eject via NoEjectDelay -->
        <item>
            <name>Eject to Ctrl+Backtick</name>
            <appendix>Opens custom app palettes from Keyboard Maestro</appendix>
            <appendix>(+ fn-eject to eject disc.)</appendix>
            <identifier>private.eject-remap</identifier>
            <autogen>
                __KeyToKey__
                ConsumerKeyCode::EJECT, ModifierFlag::NONE,
                KeyCode::BACKQUOTE, ModifierFlag::CONTROL_L
            </autogen>
            <autogen>
                __KeyToKey__
                ConsumerKeyCode::EJECT, ModifierFlag::FN,
                KeyCode::VK_OPEN_URL_SHELL_eject_disc,
            </autogen>
        </item>
        <!-- Toggle Function Keys -->
        <!-- STILL NEEDS A NOTIFICATION -->
        <item>
            <name>fn+escape to toggle f-keys</name>
            <identifier>fnesc</identifier>
            <autogen>
                __KeyToKey__
                KeyCode::ESCAPE, ModifierFlag::FN | ModifierFlag::NONE,
                KeyCode::VK_CONFIG_TOGGLE_fkeys
            </autogen>
        </item>
        <item>
          <name>fkeys</name>
          <identifier vk_config="true">fkeys</identifier>
          <autogen>__KeyToKey__ ConsumerKeyCode::BRIGHTNESS_DOWN, KeyCode::F1</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::BRIGHTNESS_UP, KeyCode::F2</autogen>
          <autogen>__KeyToKey__ KeyCode::EXPOSE_ALL, KeyCode::F3</autogen>
          <autogen>__KeyToKey__ KeyCode::LAUNCHPAD, KeyCode::F4</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::KEYBOARDLIGHT_LOW, KeyCode::F5</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::KEYBOARDLIGHT_HIGH, KeyCode::F6</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PREV, KeyCode::F7</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_PLAY, KeyCode::F8</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::MUSIC_NEXT, KeyCode::F9</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_MUTE, KeyCode::F10</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_DOWN, KeyCode::F11</autogen>
          <autogen>__KeyToKey__ ConsumerKeyCode::VOLUME_UP, KeyCode::F12</autogen>
          <autogen>__KeyToKey__ KeyCode::F1, ConsumerKeyCode::BRIGHTNESS_DOWN</autogen>
          <autogen>__KeyToKey__ KeyCode::F2, ConsumerKeyCode::BRIGHTNESS_UP</autogen>
          <autogen>__KeyToKey__ KeyCode::F3, KeyCode::EXPOSE_ALL</autogen>
          <autogen>__KeyToKey__ KeyCode::F4, KeyCode::LAUNCHPAD</autogen>
          <autogen>__KeyToKey__ KeyCode::F5, ConsumerKeyCode::KEYBOARDLIGHT_LOW</autogen>
          <autogen>__KeyToKey__ KeyCode::F6, ConsumerKeyCode::KEYBOARDLIGHT_HIGH</autogen>
          <autogen>__KeyToKey__ KeyCode::F7, ConsumerKeyCode::MUSIC_PREV</autogen>
          <autogen>__KeyToKey__ KeyCode::F8, ConsumerKeyCode::MUSIC_PLAY</autogen>
          <autogen>__KeyToKey__ KeyCode::F9, ConsumerKeyCode::MUSIC_NEXT</autogen>
          <autogen>__KeyToKey__ KeyCode::F10, ConsumerKeyCode::VOLUME_MUTE</autogen>
          <autogen>__KeyToKey__ KeyCode::F11, ConsumerKeyCode::VOLUME_DOWN</autogen>
          <autogen>__KeyToKey__ KeyCode::F12, ConsumerKeyCode::VOLUME_UP</autogen>
        </item>
        <!-- Shift keys -->
        <item>
            <name>Shifts to Parentheses</name>
            <appendix>Shifts, when pressed alone, type parentheses.  When used with other keys they're normal shifts.</appendix>
            <identifier>private.shifts_to_parens</identifier>
            <!-- This is the basic mapping. -->
            <autogen>
                --KeyOverlaidModifier--
                KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::SHIFT_R,
                KeyCode::KEY_0, ModifierFlag::SHIFT_L
            </autogen>
            <autogen>
                --KeyOverlaidModifier--
                KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::SHIFT_L,
                KeyCode::KEY_9, ModifierFlag::SHIFT_R
            </autogen>
            <!--
                Remap the "rolls" of () and )( because it's too easy to hit one
                before finishing the other, and there's no other reason to be
                pressing both shift keys at once anyway
            -->
            <autogen>
                --KeyToKey--
                KeyCode::SHIFT_L, ModifierFlag::SHIFT_R,
                KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L
            </autogen>
            <autogen>
                --KeyToKey--
                KeyCode::SHIFT_R, ModifierFlag::SHIFT_L,
                KeyCode::KEY_9, ModifierFlag::SHIFT_L, KeyCode::KEY_0, ModifierFlag::SHIFT_L
            </autogen>
            <!--
                Remap Rshift+Space to ') ', because when typing an end paren and
                then a space I tend to hit space before I let go of rshift.
            -->
            <autogen>
                --KeyToKey--
                KeyCode::SPACE, ModifierFlag::SHIFT_R,
                KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::SPACE
            </autogen>
        </item>
        <!--
            Google Chrome and Safari only Quit when pressing `CMD+Q,Q`
        -->
        <item>
            <name>Press Command+Q twice to Quit Browser</name>
            <identifier>private.doublepresscommandQinBrowsers</identifier>
            <only>SAFARI, GOOGLE_CHROME</only>
            <modifier_not>
                ModifierFlag::CONTROL_L,
                ModifierFlag::CONTROL_R,
                ModifierFlag::OPTION_L,
                ModifierFlag::OPTION_R,
                ModifierFlag::SHIFT_L,
                ModifierFlag::SHIFT_R,
            </modifier_not>
            <autogen>
                __DoublePressModifier__
                KeyCode::Q, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND,
                KeyCode::VK_NONE,
                KeyCode::Q, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND
            </autogen>
        </item>

        <!-- SHELL COMMANDS GROUP -->

        <!-- Skype Mute Toggle -->
        <item>
            <name>2x right-shift to mute Skype</name>
            <identifier>private.remap_2x-shift-l</identifier>
            <appendix>Mutes Skype via the command-line</appendix>
            <appendix>(triggers an AppleScript based Automator workflow)</appendix>
            <autogen>
                __DoublePressModifier__
                KeyCode::SHIFT_R, KeyCode::SHIFT_R,
                KeyCode::VK_OPEN_URL_SHELL_SkypeMuteToggle,
             </autogen>
        </item>
        <vkopenurldef>
            <name>KeyCode::VK_OPEN_URL_SHELL_SkypeMuteToggle</name>
            <url type="shell">
                <![CDATA[
                            RUNBIN=/usr/bin/automator
                            WORKFLOW="/Users/$(echo "$USER")/Scripts/Workflows/SkypeMuteToggle.workflow"
                            "$RUNBIN" "$WORKFLOW"
                ]]>
            </url>
        </vkopenurldef>
    </item>
    <!-- APP LAUNCHER GROUP -->
    <!-- Reference: https://github.com/tekezo/Karabiner/blob/master/src/core/server/Resources/include/checkbox/launcher_mode.xml -->
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_FILE_Scripts</name>
        <url type="file">{{ ENV_HOME }}/Scripts</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_FILE_Ubercast</name>
        <url type="file">{{ ENV_HOME }}/Ubercast</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_FILE_Rocketink</name>
        <url type="file">{{ ENV_HOME }}/Sites/rocketink.net</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_iTerm</name>
        <url type="file">/Applications/iTerm.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_Due</name>
        <url type="file">/Applications/Due.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_nvALT</name>
        <url type="file">/Applications/nvALT.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_Karabiner</name>
        <url type="file">/Applications/Karabiner.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_MailMate</name>
        <url type="file">/Applications/MailMate.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_Path_Finder</name>
        <url type="file">/Applications/Path Finder.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_Sublime_Text</name>
        <url type="file">/Applications/Sublime Text.app</url>
    </vkopenurldef>
    <vkopenurldef>
        <name>KeyCode::VK_OPEN_URL_APP_Safari</name>
        <url type="file">/Applications/Safari.app</url>
    </vkopenurldef>
    <replacementdef>
        <replacementname>LAUNCHER_MODE_V2_EXTRA</replacementname>
        <replacementvalue>
        <![CDATA[
            <autogen>
                __KeyToKey__
                KeyCode::F,
                KeyCode::VK_NONE,

                Option::KEYTOKEY_DELAYED_ACTION,
                KeyCode::VK_OPEN_URL_APP_Finder,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::D,
                KeyCode::VK_OPEN_URL_FILE_Desktop,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::S,
                KeyCode::VK_OPEN_URL_FILE_Scripts,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::U,
                KeyCode::VK_OPEN_URL_FILE_Ubercast,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::R,
                KeyCode::VK_OPEN_URL_FILE_Rocketink,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::F,
                KeyCode::VK_OPEN_URL_FILE_Home,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,
            </autogen>
            <autogen>
                __KeyToKey__
                KeyCode::D,
                KeyCode::VK_NONE,

                Option::KEYTOKEY_DELAYED_ACTION,
                KeyCode::MISSION_CONTROL, ModifierFlag::COMMAND_L,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::D,
                KeyCode::VK_OPEN_URL_APP_Due,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::T,
                KeyCode::VK_OPEN_URL_APP_iTerm,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::N,
                KeyCode::VK_OPEN_URL_APP_nvALT,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::K,
                KeyCode::VK_OPEN_URL_APP_Karabiner,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::M,
                KeyCode::VK_OPEN_URL_APP_MailMate,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::P,
                KeyCode::VK_OPEN_URL_APP_Path_Finder,
            </autogen>
            <autogen>
                __KeyToKey__
                KeyCode::S,
                KeyCode::VK_NONE,

                Option::KEYTOKEY_DELAYED_ACTION,
                KeyCode::VK_OPEN_URL_APP_Sublime_Text,

                Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::S,
                KeyCode::VK_OPEN_URL_APP_Safari,
                KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,
            </autogen>
            <autogen>
                __KeyDownUpToKey__
                KeyCode::S,
                KeyCode::VK_OPEN_URL_APP_Sublime_Text,
            </autogen>
        ]]>
        </replacementvalue>
    </replacementdef>
</root>