Last active
December 19, 2015 03:39
-
-
Save indirect/5891371 to your computer and use it in GitHub Desktop.
Remap capslock to control on all connected keyboards (now with a test to see if it's already done)
This file contains 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
$keyboard_ids = 'ioreg -n IOHIDKeyboard -r | grep -E \'VendorID"|ProductID\' | awk \'{ print $4 }\' | paste -s -d\'-\n\' -' | |
$check = 'xargs -I{} sh -c \'defaults -currentHost read -g "com.apple.keyboard.modifiermapping.{}-0" | grep "Dst = 2" > /dev/null\'' | |
$remap = 'xargs -I{} defaults -currentHost write -g "com.apple.keyboard.modifiermapping.{}-0" -array "<dict><key>HIDKeyboardModifierMappingDst</key><integer>2</integer><key>HIDKeyboardModifierMappingSrc</key><integer>0</integer></dict>"' | |
exec { 'Remap capslock to control on all keyboards': | |
command => "${keyboard_ids} | ${remap}", | |
unless => "${keyboard_ids} | ${check}" | |
} |
This file contains 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
ioreg -n IOHIDKeyboard -r | grep -E 'VendorID"|ProductID' | awk '{ print $4 }' | paste -s -d'-\n' - | xargs -I{} /usr/bin/defaults -currentHost write -g "com.apple.keyboard.modifiermapping.{}-0" -array "<dict><key>HIDKeyboardModifierMappingDst</key><integer>2</integer><key>HIDKeyboardModifierMappingSrc</key><integer>0</integer></dict>" |
It seems to. Thanks for putting this together!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@indirect I'm trying boxen for the first time, and I'd like to add this to my
people/manifests/amiel.pp
. Will it work to pasteremap.pp
in?