Last active
February 20, 2022 10:37
-
-
Save BlvckBytes/dad23669583ba67a439f20cbbdffec3e to your computer and use it in GitHub Desktop.
Override keys on macOS in a way that I'm used to
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 | |
| ERR=`launchctl unload dev.blvckbytes.kbremap.plist 2>&1` | |
| launchctl load dev.blvckbytes.kbremap.plist | |
| [ -z "$ERR" ] && echo "Updated launchd!" || echo "Installed launchd!" |
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
| <?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>kbremap</string> | |
| <!-- Set the target user --> | |
| <!-- They need to have .config/kbremap/keyremapping.js in ~ (home) --> | |
| <key>UserName</key> | |
| <string>blvckbytes</string> | |
| <key>ProgramArguments</key> | |
| <array> | |
| <string>/bin/bash</string> | |
| <string>-c</string> | |
| <!-- Get remap file content, strip out comments, join all lines, wrap in single quotes and prefix by the required args, then run that using hidutil --> | |
| <string>cat ~/.config/kbremap/keyremapping.js | sed -E 's|^([^/]*)//.*$|\1|g' | awk 'BEGIN {ORS=""; print "property --set \x27"} {ORS=""; print} END {ORS=""; print "\x27"}' | xargs hidutil</string> | |
| </array> | |
| <key>RunAtLoad</key> | |
| <true/> | |
| </dict> | |
| </plist> |
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
| { | |
| "UserKeyMapping":[ | |
| // CAPS_LOCK to ESCAPE | |
| { | |
| "HIDKeyboardModifierMappingSrc": 0x700000039, | |
| "HIDKeyboardModifierMappingDst": 0x700000029 | |
| }, | |
| // NON_US_BACKSLASH to GRAVE_ACCENT_AND_TILDE | |
| // On DE this overrides (°/^) with (</>) | |
| { | |
| "HIDKeyboardModifierMappingSrc": 0x700000064, | |
| "HIDKeyboardModifierMappingDst": 0x700000035 | |
| }, | |
| // GRAVE_ACCENT_AND_TILDE to NON_US_BACKSLASH | |
| // On DE this overrides (</>) with (°/^) | |
| { | |
| "HIDKeyboardModifierMappingSrc": 0x700000035, | |
| "HIDKeyboardModifierMappingDst": 0x700000064 | |
| } | |
| ] | |
| } |
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 | |
| hidutil property --set '{"UserKeyMapping":[]}' | |
| echo "Reset mappings!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment