this question is similar to Changing modifier keys from the command line
I wanted to remap Right Command to Right Option since I'm using Apple Magic Keyboard with numeric pad, but on my MacBook Pro 13" the Right Option key is much closer to L, and I keep using that combination since I'm Polish speaker. Anyways I tried remapping my keys using this:
ioreg -n IOBluetoothHCIController -r | grep -e 'class AppleHSBluetoothInterface' -e VendorID\" -e Product
which returned
| "ActiveControllerInfo" = {"ActiveControllerProductID"=126,"ActiveControllerActiveConnections"=2,"ActiveControllerLocationID"=0,"ActiveControllerVendorID"=1452,"ActiveControllerAddress"=<8c85902c0687>}
| "80-4a-14-7f-47-99" = {"VendorIDSource"=1,"LinkSupervisionTimeout"=8000,"VendorID"=76,"CountryCode"=33,"HIDVirtualDevice"=No,"Product"="Wkurwibord","VersionNumber"=256,"QoSLatency"=11250,"ProductID"=620,"Transport"="Bluetooth","ReportDescriptor"=<05010906a101850105071500250119e029e775019508810295057501050819012905910295017503910395087501150025010600ff0903810395067508150026ff00050719002aff0081009501750115002501050c09b88102950175010601ff090381029501750681030602ff09558555150026ff0075089540b1a2c00600ff0914a101859005847501950315002501096105850944094681029505810175089501150026ff0009658102c0>,"ClassOfDevice"=1344,"BootDevice"=Yes,"ConfiguredNotPaired"=No}
| "idProduct" = 126
| | +-o Device Management@0 <class AppleHSBluetoothInterface, id 0x1000005bb, registered, matched, active, busy 0 (469 ms), retain 7>
| | +-o Keyboard / Boot@1 <class AppleHSBluetoothInterface, id 0x1000005bc, registered, matched, active, busy 0 (90 ms), retain 7>
So I tried
defaults -currentHost write -g com.apple.keyboard.modifiermapping.1452-126-0 -array-add '<dict><key>HIDKeyboardModifierMappingDst</key><integer>30064771302</integer><key>HIDKeyboardModifierMappingSrc</key><integer>30064771303</integer></dict>'
values being described as 0x70000000 OR'd with data in table at this location: https://developer.apple.com/library/archive/technotes/tn2450/_index.html
But whatever combination I used for product and vendor IDs this just wouldn't work. When I checked how macOS system keyboard applet does that I found this by searching with grep:
"com.apple.keyboard.modifiermapping.alt_handler_id-61" = (
{
HIDKeyboardModifierMappingDst = 30064771302;
HIDKeyboardModifierMappingSrc = 30064771303;
}
);
So, what is alt_handler_id-61? I would be grateful if someone could send me to some documentation. I would like to write this down for the future when I might change to another Mac or reformat the system. Thank you!