Last active
October 13, 2019 06:40
-
-
Save callemo/9b43c54298b4565dd2521cc7b6258717 to your computer and use it in GitHub Desktop.
Remapping Keys in macOS
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 | |
# Remapping Keys in macOS | |
# https://developer.apple.com/library/archive/technotes/tn2450/_index.html | |
set -e | |
userscript="$HOME/bin/userkeymap" | |
mkdir -p "$HOME"/bin | |
cat <<EOF > "$userscript" | |
#!/bin/bash | |
hidutil property --set '{"UserKeyMapping": [ | |
{"HIDKeyboardModifierMappingSrc": 0x700000064, "HIDKeyboardModifierMappingDst": 0x700000035} | |
]}' | |
EOF | |
mkdir -p "$HOME/Library/LaunchAgents" | |
cat<<EOF >"$HOME/Library/LaunchAgents/userkeymap.plist" | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>userkeymap</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>$userscript</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> | |
EOF | |
chmod +x "$userscript" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment