Created
December 13, 2017 17:25
-
-
Save bradhowes/cc73d7dd81837f6f30e701e7f1a0bee0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Custom mapping for Apple MacBookPro 2017 keyboard. | |
# | |
# - Map §/± (SECTION) to `/~ (BACKQUOTE) to match US keyboard | |
# - Map CAPS LOCK (LOCK) to SHIFT (L_SHIFT) to locking | |
# - Map right CMD (R_CMD) to CAPS LOCK to enable locking if really wanted | |
# - Map `/~ to (BACKQUOTE) to SHIFT (L_SHIFT) to make SHIFT-^ easier | |
# | |
# To run at startup: | |
# sudo defaults write com.apple.loginwindow LoginHook `pwd`/remap.sh | |
# https://developer.apple.com/library/content/technotes/tn2450/_index.html | |
# | |
# Derived from https://gist.github.com/zbstof/6cba7d54e105cc5148c8a943d1581cad | |
FROM='"HIDKeyboardModifierMappingSrc"' | |
TO='"HIDKeyboardModifierMappingDst"' | |
ARGS="" | |
function Map # FROM TO | |
{ | |
CMD="${CMD:+${CMD},}{${FROM}: ${1}, ${TO}: ${2}}" | |
} | |
BACKQUOTE="0x700000035" | |
LOCK="0x700000039" | |
SECTION="0x700000064" | |
L_SHIFT="0x7000000E1" | |
R_CMD="0x7000000E7" | |
Map ${SECTION} ${BACKQUOTE} | |
Map ${LOCK} ${L_SHIFT} | |
Map ${R_CMD} ${LOCK} | |
Map ${BACKQUOTE} ${L_SHIFT} | |
hidutil property --set "{\"UserKeyMapping\":[${CMD}]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment