Skip to content

Instantly share code, notes, and snippets.

@mattbailey
Last active February 23, 2024 12:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbailey/9429c7691467bf82d64e1900c99fb53b to your computer and use it in GitHub Desktop.
Save mattbailey/9429c7691467bf82d64e1900c99fb53b to your computer and use it in GitHub Desktop.
macos plist for remapping caps lock to left control, and right control to Fn which you can't do in system settings
<!--
Generated with: https://hidutil-generator.netlify.app/
Put in new file: ~/Library/LaunchAgents/com.local.KeyRemapping.plist
load with:
$ launchctl load ~/Library/LaunchAgents/com.local.KeyRemapping.plist
unload with (if you change it):
$ launchctl unload ~/Library/LaunchAgents/com.local.KeyRemapping.plist
should preserve through reboots.
I did this because I needed a Fn key on my external non-mac keyboard because
I use yabai (github.com/koekeishiya/yabai) for window management on macos, and the Fn key
works as a mouse modifier to drag around windows. I also prefer the caps_lock button
to be control, but if you do this in system settings/modifier keys,
it sets caps_lock to right_control, which would then get re-mapped here to Fn.
-->
<?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.local.KeyRemapping</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<!-- caps_lock to left_control, right_control to fn -->
<string>{"UserKeyMapping":[
{
"HIDKeyboardModifierMappingSrc": 0x700000039,
"HIDKeyboardModifierMappingDst": 0x7000000E0
},
{
"HIDKeyboardModifierMappingSrc": 0x7000000E4,
"HIDKeyboardModifierMappingDst": 0xFF00000003
}
]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
<!--
right_control:
"HIDKeyboardModifierMappingSrc": 0x7000000E4,
left_control:
"HIDKeyboardModifierMappingSrc": 0x7000000E0,
caps_lock:
"HIDKeyboardModifierMappingSrc": 0x700000039,
fn(dest):
"HIDKeyboardModifierMappingDst": 0xFF00000003
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment