Skip to content

Instantly share code, notes, and snippets.

@marinomeneghel
Last active March 22, 2021 14:49
Show Gist options
  • Save marinomeneghel/52dcfecd9cf73b003c952bf14780faeb to your computer and use it in GitHub Desktop.
Save marinomeneghel/52dcfecd9cf73b003c952bf14780faeb to your computer and use it in GitHub Desktop.
Remap IT / EU keyboard to US
# Keyboard custom mapping
# backslash to enter
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000031,"HIDKeyboardModifierMappingDst":0x700000028}]}'
# tilde to backslash
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000031}]}'
# EU backslash to tilde
dutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
# To apply changes to an external BT keyboard ProductID is needed
```
hidutil property --matching '{"ProductID":{prod_id}}' --set '{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000031},
{"HIDKeyboardModifierMappingSrc":0x700000031,"HIDKeyboardModifierMappingDst":0x700000028}
]}'
```
### Full 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>com.example.setkeyboard</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--matching</string>
<string>{"ProductID": {prod_id}}</string>
<string>--set</string>
<string>{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000031},
{"HIDKeyboardModifierMappingSrc":0x700000031,"HIDKeyboardModifierMappingDst":0x700000028}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment