From 636d1a09d8a4fc2306aee0c8a33dac21bd9e201a Mon Sep 17 00:00:00 2001 From: Maxime Daffis Date: Tue, 2 Jul 2024 14:22:37 +0200 Subject: [PATCH] (feature) Add swapLeftCtrlAndFn Use this and never find yourself again hitting fn because of muscle memory! (you can even physically swap the keycaps, at least on M series) Keycodes have been pulled from https://hidutil-generator.netlify.app/ and the hex value has been converted to a base 10 int. --- modules/system/keyboard.nix | 14 ++++++++++++++ tests/system-keyboard-mapping.nix | 3 +++ 2 files changed, 17 insertions(+) diff --git a/modules/system/keyboard.nix b/modules/system/keyboard.nix index 01e25256..f4f64060 100644 --- a/modules/system/keyboard.nix +++ b/modules/system/keyboard.nix @@ -38,6 +38,12 @@ in description = "Whether to swap the left Command key and left Alt key."; }; + system.keyboard.swapLeftCtrlAndFn = mkOption { + type = types.bool; + default = false; + description = "Whether to swap the left Control key and Fn (Globe) key."; + }; + system.keyboard.userKeyMapping = mkOption { internal = true; type = types.listOf (types.attrsOf types.int); @@ -66,6 +72,14 @@ in HIDKeyboardModifierMappingSrc = 30064771298; HIDKeyboardModifierMappingDst = 30064771299; }) + (mkIf cfg.swapLeftCtrlAndFn { + HIDKeyboardModifierMappingSrc = 30064771296; + HIDKeyboardModifierMappingDst = 1095216660483; + }) + (mkIf cfg.swapLeftCtrlAndFn { + HIDKeyboardModifierMappingSrc = 1095216660483; + HIDKeyboardModifierMappingDst = 30064771296; + }) ]; system.activationScripts.keyboard.text = optionalString cfg.enableKeyMapping '' diff --git a/tests/system-keyboard-mapping.nix b/tests/system-keyboard-mapping.nix index b75efbd3..654ca0c9 100644 --- a/tests/system-keyboard-mapping.nix +++ b/tests/system-keyboard-mapping.nix @@ -6,6 +6,7 @@ system.keyboard.remapCapsLockToEscape = true; system.keyboard.nonUS.remapTilde = true; system.keyboard.swapLeftCommandAndLeftAlt = true; + system.keyboard.swapLeftCtrlAndFn = true; test = '' echo checking keyboard mappings in /activate >&2 @@ -17,5 +18,7 @@ grep "\"HIDKeyboardModifierMappingDst\":30064771296" ${config.out}/activate grep "\"HIDKeyboardModifierMappingDst\":30064771298" ${config.out}/activate grep "\"HIDKeyboardModifierMappingDst\":30064771299" ${config.out}/activate + grep "\"HIDKeyboardModifierMappingDst\":30064771296" ${config.out}/activate + grep "\"HIDKeyboardModifierMappingDst\":1095216660483" ${config.out}/activate ''; }