summaryrefslogtreecommitdiff
path: root/modules/system/defaults-write.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/defaults-write.nix')
-rw-r--r--modules/system/defaults-write.nix25
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix
index 7e1fc44..2265721 100644
--- a/modules/system/defaults-write.nix
+++ b/modules/system/defaults-write.nix
@@ -9,20 +9,24 @@ let
"defaults write ${domain} '${key}' $'${strings.escape [ "'" ] (generators.toPlist { } value)}'";
defaultsToList = domain: attrs: mapAttrsToList (writeDefault domain) (filterAttrs (n: v: v != null) attrs);
+ # Filter out options to not pass through
+ # dock has alias options that we need to ignore
+ dockFiltered = (builtins.removeAttrs cfg.dock ["expose-group-by-app"]);
# defaults
alf = defaultsToList "/Library/Preferences/com.apple.alf" cfg.alf;
loginwindow = defaultsToList "/Library/Preferences/com.apple.loginwindow" cfg.loginwindow;
smb = defaultsToList "/Library/Preferences/SystemConfiguration/com.apple.smb.server" cfg.smb;
- SoftwareUpdate = defaultsToList "/Library/Preferences/SystemConfiguration/com.apple.SoftwareUpdate" cfg.SoftwareUpdate;
+ SoftwareUpdate = defaultsToList "/Library/Preferences/com.apple.SoftwareUpdate" cfg.SoftwareUpdate;
# userDefaults
GlobalPreferences = defaultsToList ".GlobalPreferences" cfg.".GlobalPreferences";
LaunchServices = defaultsToList "com.apple.LaunchServices" cfg.LaunchServices;
NSGlobalDomain = defaultsToList "-g" cfg.NSGlobalDomain;
menuExtraClock = defaultsToList "com.apple.menuextra.clock" cfg.menuExtraClock;
- dock = defaultsToList "com.apple.dock" cfg.dock;
+ dock = defaultsToList "com.apple.dock" dockFiltered;
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;
@@ -32,9 +36,12 @@ let
trackpadBluetooth = defaultsToList "com.apple.driver.AppleBluetoothMultitouch.trackpad" cfg.trackpad;
universalaccess = defaultsToList "com.apple.universalaccess" cfg.universalaccess;
ActivityMonitor = defaultsToList "com.apple.ActivityMonitor" cfg.ActivityMonitor;
+ WindowManager = defaultsToList "com.apple.WindowManager" cfg.WindowManager;
+ controlcenter = defaultsToList "~/Library/Preferences/ByHost/com.apple.controlcenter" cfg.controlcenter;
CustomUserPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomUserPreferences);
CustomSystemPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomSystemPreferences);
+
mkIfAttrs = list: mkIf (any (attrs: attrs != { }) list);
in
@@ -75,6 +82,7 @@ in
menuExtraClock
dock
finder
+ hitoolbox
magicmouse
magicmouseBluetooth
screencapture
@@ -85,6 +93,8 @@ in
universalaccess
ActivityMonitor
CustomUserPreferences
+ WindowManager
+ controlcenter
]
''
# Set defaults
@@ -97,6 +107,7 @@ in
${concatStringsSep "\n" menuExtraClock}
${concatStringsSep "\n" dock}
${concatStringsSep "\n" finder}
+ ${concatStringsSep "\n" hitoolbox}
${concatStringsSep "\n" magicmouse}
${concatStringsSep "\n" magicmouseBluetooth}
${concatStringsSep "\n" screencapture}
@@ -107,6 +118,16 @@ in
${concatStringsSep "\n" universalaccess}
${concatStringsSep "\n" ActivityMonitor}
${concatStringsSep "\n" CustomUserPreferences}
+ ${concatStringsSep "\n" WindowManager}
+ ${concatStringsSep "\n" controlcenter}
+
+ ${optionalString (length dock > 0) ''
+ # Only restart Dock if current user is logged in
+ if pgrep -xu $UID Dock >/dev/null; then
+ echo >&2 "restarting Dock..."
+ killall Dock || true
+ fi
+ ''}
'';
};