Created
September 18, 2019 20:48
-
-
Save marianopeterson/0f72ceed81b9d69932414d5c39e1a142 to your computer and use it in GitHub Desktop.
keyboard function
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
function keyboard { | |
local OS_KEY="0x7000000E2" | |
local LEFT_ALT_KEY="0x7000000E3" | |
local SRC='"HIDKeyboardModifierMappingSrc"' | |
local DST='"HIDKeyboardModifierMappingDst"' | |
usage() { | |
echo "usage: ${FUNCNAME[1]} [-h | mac | win ]" | |
echo "" | |
echo " Toggles keyboard mapping between Mac and Windows keyboards" | |
echo "" | |
echo " mac Restores factory settings by removing key overrides" | |
echo " win Remaps the [⊞ WIN] key to [⌥ Option], and the [Alt] key to [⌘ Command]" | |
} | |
if [[ $# -eq 0 ]]; then | |
usage | |
return | |
fi | |
case "$1" in | |
-h|--help|help) | |
usage | |
return ;; | |
apple|mac|macos|reset) | |
# reset them to do their normal thing | |
hidutil property --set "{\"UserKeyMapping\":[ {$SRC:$OS_KEY, $DST:$OS_KEY}, {$SRC:$LEFT_ALT_KEY, $DST:$LEFT_ALT_KEY} ]}" | |
return ;; | |
microsoft|ms|win|windows) | |
# swap command and alt keys | |
hidutil property --set "{\"UserKeyMapping\":[ {$SRC:$OS_KEY, $DST:$LEFT_ALT_KEY}, {$SRC:$LEFT_ALT_KEY, $DST:$OS_KEY} ]}" | |
return ;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment