Skip to content

Instantly share code, notes, and snippets.

@ticklemynausea
Last active September 7, 2022 00:39
Show Gist options
  • Save ticklemynausea/71b0535f9b683a9c6eb974458163daba to your computer and use it in GitHub Desktop.
Save ticklemynausea/71b0535f9b683a9c6eb974458163daba to your computer and use it in GitHub Desktop.
#!/bin/bash
# Makes the portuguese windows keyboard layout work in osx -
# whatever the key is labeled will be matched to the keystroke, with a caveat:
#
# Windows and apple keyboards have an exclusive key to each - "french quotation marks" key («»)
# is exclusive to windows layouts and the "paragraph / plus minus" key (§±) is exclusive to apple
# layouts. This configuration will make the exclusive windows key behave as apple's.
#
# The configuration is not scoped to a particular keyboard, so to restore the default behavior of
# the laptop keyboard, run this script with -c.
if [[ $1 == '-c' ]]; then
hidutil property --set '{"UserKeyMapping":[]}'
exit 0
fi
hidutil property --set '{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x700000032},
{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},
{"HIDKeyboardModifierMappingSrc":0x70000002E,"HIDKeyboardModifierMappingDst":0x700000064},
{"HIDKeyboardModifierMappingSrc":0x70000002F,"HIDKeyboardModifierMappingDst":0x70000002E},
{"HIDKeyboardModifierMappingSrc":0x700000034,"HIDKeyboardModifierMappingDst":0x70000002F},
{"HIDKeyboardModifierMappingSrc":0x700000032,"HIDKeyboardModifierMappingDst":0x700000034}
]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment