Skip to content

Instantly share code, notes, and snippets.

@zbstof
Last active August 12, 2021 14:21
Show Gist options
  • Save zbstof/6cba7d54e105cc5148c8a943d1581cad to your computer and use it in GitHub Desktop.
Save zbstof/6cba7d54e105cc5148c8a943d1581cad to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# To run at startup:
# sudo defaults write com.apple.loginwindow LoginHook `pwd`/remap.sh
# https://developer.apple.com/library/content/technotes/tn2450/_index.html
CAPS_LOCK="0x700000039"
ESCAPE="0x700000029"
NON_US_BACKSLASH_PLUS_MINUS="0x700000064"
GRAVE_ACCENT_AND_TILDE="0x700000035"
SLASH_PIPE="0x700000031"
ENTER_RETURN="0x700000028"
RIGHT_SHIFT="0x7000000E5" #Do nothing button
FROM="\"HIDKeyboardModifierMappingSrc\""
TO="\"HIDKeyboardModifierMappingDst\""
hidutil property --set "{\"UserKeyMapping\":[
{$FROM: $CAPS_LOCK, $TO: $ESCAPE},
{$FROM: $ESCAPE, $TO: $RIGHT_SHIFT},
{$FROM: $GRAVE_ACCENT_AND_TILDE, $TO: $SLASH_PIPE},
{$FROM: $SLASH_PIPE, $TO: $ENTER_RETURN},
{$FROM: $NON_US_BACKSLASH_PLUS_MINUS, $TO: $GRAVE_ACCENT_AND_TILDE}
]}"
@zbstof
Copy link
Author

zbstof commented Nov 21, 2020

Hm, don't know how to help you. The table provided in the technotes doesn't have Fn listed

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