Last active
April 5, 2017 17:06
-
-
Save brewski/f418f4d1a3fa893ac2e38f9f0c69a665 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# The easiest way to figure this out is to create a re-remapping in System Preferences ui, and then | |
# `defaults -currentHost read | grep com.apple.keyboard.modifiermapping` | |
keyboard_id="1452-632-0" | |
config_key="com.apple.keyboard.modifiermapping.${keyboard_id}" | |
# key_left_cmd=30064771299 | |
key_right_cmd=30064771303 | |
key_esc=30064771113 | |
key_caps_lock=30064771129 | |
key_ctrl=30064771296 | |
for plist in `ls ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist`; do | |
/usr/libexec/PlistBuddy -c "Delete $config_key" $plist &> /dev/null | |
/usr/libexec/PlistBuddy -c "Add $config_key array" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key: dict" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key:0:HIDKeyboardModifierMappingSrc integer $key_right_cmd" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key:0:HIDKeyboardModifierMappingDst integer $key_esc" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key: dict" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key:1:HIDKeyboardModifierMappingSrc integer $key_caps_lock" $plist | |
/usr/libexec/PlistBuddy -c "Add $config_key:1:HIDKeyboardModifierMappingDst integer $key_ctrl" $plist | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment