From 02ff8573ea1be68f8d75e88e7942571c986fbdb3 Mon Sep 17 00:00:00 2001 From: xenia Date: Tue, 12 Mar 2024 19:59:35 +0100 Subject: [PATCH] Change remap from script to system.keyboard.userKeyMapping --- darwin.nix | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/darwin.nix b/darwin.nix index 7546901f..3597fc7f 100644 --- a/darwin.nix +++ b/darwin.nix @@ -57,30 +57,28 @@ system.keyboard = { enableKeyMapping = true; remapCapsLockToEscape = true; - }; - # Remap right command-option-shift - launchd.user.agents.swap-keys = { - serviceConfig = { - ProgramArguments = [ - "/usr/bin/hidutil" "property" "--set" '' - {"UserKeyMapping": - [ - { - "HIDKeyboardModifierMappingSrc":0x7000000e7, - "HIDKeyboardModifierMappingDst":0x7000000e1 - }, { - "HIDKeyboardModifierMappingSrc":0x7000000e5, - "HIDKeyboardModifierMappingDst":0x7000000e6 - }, { - "HIDKeyboardModifierMappingSrc":0x7000000e6, - "HIDKeyboardModifierMappingDst":0x7000000e3 - } - ] - } - '' - ]; - RunAtLoad = true; - }; + # remap right hand side modifier keys + # https://developer.apple.com/library/archive/technotes/tn2450/_index.html + userKeyMapping = let + lshift = 30064771297; # 0x7000000e1 + lcmd = 30064771299; # 0x7000000e3 + rshift = 30064771301; # 0x7000000e5 + ropt = 30064771302; # 0x7000000e6 + rcmd = 30064771303; # 0x7000000e7 + in [ + { + HIDKeyboardModifierMappingSrc = rcmd; + HIDKeyboardModifierMappingDst = rshift; + } + { + HIDKeyboardModifierMappingSrc = rshift; + HIDKeyboardModifierMappingDst = ropt; + } + { + HIDKeyboardModifierMappingSrc = ropt; + HIDKeyboardModifierMappingDst = rcmd; + } + ]; }; }