Skip to content

Instantly share code, notes, and snippets.

@indirect indirect/remap.pp
Last active Dec 19, 2015

Embed
What would you like to do?
Remap capslock to control on all connected keyboards (now with a test to see if it's already done)
$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}"
}
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>"
@amiel

This comment has been minimized.

Copy link

commented Nov 6, 2013

@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 paste remap.pp in?

@amiel

This comment has been minimized.

Copy link

commented Nov 7, 2013

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
You can’t perform that action at this time.