From 21809c4261a421eb06b2d7b3ccd18ebadd921f96 Mon Sep 17 00:00:00 2001 From: April Schleck Date: Sun, 27 Oct 2024 23:37:08 -0700 Subject: [PATCH] Allow configuring the fn key action --- modules/module-list.nix | 1 + modules/system/defaults-write.nix | 3 ++ modules/system/defaults/hitoolbox.nix | 29 +++++++++++++++++++ .../system-defaults-write/activate-user.txt | 5 ++++ tests/system-defaults-write.nix | 1 + 5 files changed, 39 insertions(+) create mode 100644 modules/system/defaults/hitoolbox.nix diff --git a/modules/module-list.nix b/modules/module-list.nix index effdff76..5477fad6 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -21,6 +21,7 @@ ./system/defaults/clock.nix ./system/defaults/dock.nix ./system/defaults/finder.nix + ./system/defaults/hitoolbox.nix ./system/defaults/screencapture.nix ./system/defaults/screensaver.nix ./system/defaults/alf.nix diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index e7f2c034..7af972d6 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -23,6 +23,7 @@ let menuExtraClock = defaultsToList "com.apple.menuextra.clock" cfg.menuExtraClock; dock = defaultsToList "com.apple.dock" cfg.dock; finder = defaultsToList "com.apple.finder" cfg.finder; + hitoolbox = defaultsToList "com.apple.HIToolbox" cfg.hitoolbox; magicmouse = defaultsToList "com.apple.AppleMultitouchMouse" cfg.magicmouse; magicmouseBluetooth = defaultsToList "com.apple.driver.AppleMultitouchMouse.mouse" cfg.magicmouse; screencapture = defaultsToList "com.apple.screencapture" cfg.screencapture; @@ -76,6 +77,7 @@ in menuExtraClock dock finder + hitoolbox magicmouse magicmouseBluetooth screencapture @@ -99,6 +101,7 @@ in ${concatStringsSep "\n" menuExtraClock} ${concatStringsSep "\n" dock} ${concatStringsSep "\n" finder} + ${concatStringsSep "\n" hitoolbox} ${concatStringsSep "\n" magicmouse} ${concatStringsSep "\n" magicmouseBluetooth} ${concatStringsSep "\n" screencapture} diff --git a/modules/system/defaults/hitoolbox.nix b/modules/system/defaults/hitoolbox.nix new file mode 100644 index 00000000..c2e336b7 --- /dev/null +++ b/modules/system/defaults/hitoolbox.nix @@ -0,0 +1,29 @@ +{ lib, ... }: + +{ + options = { + + system.defaults.hitoolbox.AppleFnUsageType = lib.mkOption { + type = lib.types.nullOr (lib.types.enum [ + "Do Nothing" + "Change Input Source" + "Show Emoji & Symbols" + "Start Dictation" + ]); + apply = key: if key == null then null else { + "Do Nothing" = 0; + "Change Input Source" = 1; + "Show Emoji & Symbols" = 2; + "Start Dictation" = 3; + }.${key}; + default = null; + description = '' + Chooses what happens when you press the Fn key on the keyboard. A restart is required for + this setting to take effect. + + The default is unset ("Show Emoji & Symbols"). + ''; + }; + + }; +} diff --git a/tests/fixtures/system-defaults-write/activate-user.txt b/tests/fixtures/system-defaults-write/activate-user.txt index f3e01a64..34ff7283 100644 --- a/tests/fixtures/system-defaults-write/activate-user.txt +++ b/tests/fixtures/system-defaults-write/activate-user.txt @@ -354,6 +354,11 @@ defaults write com.apple.finder '_FXSortFoldersFirst' $' ' +defaults write com.apple.HIToolbox 'AppleFnUsageType' $' + + +2 +' defaults write com.apple.screencapture 'location' $' diff --git a/tests/system-defaults-write.nix b/tests/system-defaults-write.nix index eae6199d..d5e0d08b 100644 --- a/tests/system-defaults-write.nix +++ b/tests/system-defaults-write.nix @@ -61,6 +61,7 @@ system.defaults.finder._FXShowPosixPathInTitle = true; system.defaults.finder._FXSortFoldersFirst = true; system.defaults.finder.FXEnableExtensionChangeWarning = false; + system.defaults.hitoolbox.AppleFnUsageType = "Show Emoji & Symbols"; system.defaults.screencapture.location = "/tmp"; system.defaults.screensaver.askForPassword = true; system.defaults.screensaver.askForPasswordDelay = 5;