From 32df51bf2b82dab724b845f4ad2d45bc1a0d0b9e Mon Sep 17 00:00:00 2001 From: Lucas Mendes Loureiro Date: Tue, 12 Nov 2024 01:24:22 +0000 Subject: [PATCH] fix(defaults): fixing #1107 --- modules/system/defaults-write.nix | 5 +- modules/system/defaults/clock.nix | 8 +++ modules/system/defaults/dock.nix | 8 +++ modules/system/defaults/finder.nix | 57 +++++++++++++++++-- modules/system/defaults/screencapture.nix | 12 ++++ .../system-defaults-write/activate-user.txt | 45 +++++++++++++++ tests/system-defaults-write.nix | 9 +++ 7 files changed, 138 insertions(+), 6 deletions(-) diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index 4249af99..87b179b8 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -17,7 +17,6 @@ let SoftwareUpdate = defaultsToList "/Library/Preferences/com.apple.SoftwareUpdate" cfg.SoftwareUpdate; # userDefaults - controlcenter = defaultsToList "~/Library/Preferences/ByHost/com.apple.controlcenter" cfg.controlcenter; GlobalPreferences = defaultsToList ".GlobalPreferences" cfg.".GlobalPreferences"; LaunchServices = defaultsToList "com.apple.LaunchServices" cfg.LaunchServices; NSGlobalDomain = defaultsToList "-g" cfg.NSGlobalDomain; @@ -35,9 +34,11 @@ let 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 @@ -72,7 +73,6 @@ in system.activationScripts.userDefaults.text = mkIfAttrs [ - controlcenter GlobalPreferences LaunchServices NSGlobalDomain @@ -91,6 +91,7 @@ in ActivityMonitor CustomUserPreferences WindowManager + controlcenter ] '' # Set defaults diff --git a/modules/system/defaults/clock.nix b/modules/system/defaults/clock.nix index 3fae4640..50eb5176 100644 --- a/modules/system/defaults/clock.nix +++ b/modules/system/defaults/clock.nix @@ -5,6 +5,14 @@ with lib; { options = { + system.defaults.menuExtraClock.FlashDateSeparators = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + When enabled, the clock indicator (which by default is the colon) will flash on and off each second. Default is null. + ''; + }; + system.defaults.menuExtraClock.IsAnalog = mkOption { type = types.nullOr types.bool; default = null; diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 5c4a4709..2d5c1619 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -149,6 +149,14 @@ in { else map (folder: { tile-data = { file-data = { _CFURLString = "file://" + folder; _CFURLStringType = 15; }; }; tile-type = if strings.hasInfix "." (last (splitString "/" folder)) then "file-tile" else "directory-tile"; }) value; }; + system.defaults.dock.scroll-to-open = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Scroll up on a Dock icon to show all Space's opened windows for an app, or open stack. The default is false. + ''; + }; + system.defaults.dock.show-process-indicators = mkOption { type = types.nullOr types.bool; default = null; diff --git a/modules/system/defaults/finder.nix b/modules/system/defaults/finder.nix index 51fff74f..5004b2c4 100644 --- a/modules/system/defaults/finder.nix +++ b/modules/system/defaults/finder.nix @@ -41,6 +41,15 @@ in ''; }; + system.defaults.finder.FXRemoveOldTrashItems = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Remove items in the trash after 30 days. + The default is false. + ''; + }; + system.defaults.finder.FXPreferredViewStyle = mkOption { type = types.nullOr types.str; default = null; @@ -55,7 +64,7 @@ in type = types.nullOr types.bool; default = null; description = '' - Whether to always show file extensions. The default is false. + Whether to always show file extensions. The default is false. ''; }; @@ -71,7 +80,39 @@ in type = types.nullOr types.bool; default = null; description = '' - Whether to allow quitting of the Finder. The default is false. + Whether to allow quitting of the Finder. The default is false. + ''; + }; + + system.defaults.finder.ShowExternalHardDrivesOnDesktop = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to show external disks on desktop. The default is true. + ''; + }; + + system.defaults.finder.ShowHardDrivesOnDesktop = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to show hard disks on desktop. The default is false. + ''; + }; + + system.defaults.finder.ShowMountedServersOnDesktop = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to show connected servers on desktop. The default is false. + ''; + }; + + system.defaults.finder.ShowRemovableMediaOnDesktop = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether to show removable media (CDs, DVDs and iPods) on desktop. The default is true. ''; }; @@ -79,7 +120,7 @@ in type = types.nullOr types.bool; default = null; description = '' - Whether to show the full POSIX filepath in the window title. The default is false. + Whether to show the full POSIX filepath in the window title. The default is false. ''; }; @@ -91,11 +132,19 @@ in ''; }; + system.defaults.finder._FXSortFoldersFirstOnDesktop = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Keep folders on top when sorting by name on the desktop. The default is false. + ''; + }; + system.defaults.finder.FXEnableExtensionChangeWarning = mkOption { type = types.nullOr types.bool; default = null; description = '' - Whether to show warnings when change the file extension of files. The default is true. + Whether to show warnings when change the file extension of files. The default is true. ''; }; diff --git a/modules/system/defaults/screencapture.nix b/modules/system/defaults/screencapture.nix index b5efc22f..80dcaabb 100644 --- a/modules/system/defaults/screencapture.nix +++ b/modules/system/defaults/screencapture.nix @@ -29,6 +29,18 @@ with lib; ''; }; + system.defaults.screencapture.include-date = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Include date and time in screenshot filenames. The default is true. + Screenshot 2024-01-09 at 13.27.20.png would be an example for true. + + Screenshot.png + Screenshot 1.png would be an example for false. + ''; + }; + system.defaults.screencapture.show-thumbnail = mkOption { type = types.nullOr types.bool; default = null; diff --git a/tests/fixtures/system-defaults-write/activate-user.txt b/tests/fixtures/system-defaults-write/activate-user.txt index 57cfe67a..f6e9bbaa 100644 --- a/tests/fixtures/system-defaults-write/activate-user.txt +++ b/tests/fixtures/system-defaults-write/activate-user.txt @@ -205,6 +205,11 @@ defaults write .GlobalPreferences 'com.apple.sound.beep.sound' $'/System/Library/Sounds/Funk.aiff ' +defaults write com.apple.menuextra.clock 'FlashDateSeparators' $' + + + +' defaults write com.apple.menuextra.clock 'Show24Hour' $' @@ -299,6 +304,11 @@ defaults write com.apple.dock 'persistent-others' $' ' +defaults write com.apple.dock 'scroll-to-open' $' + + + +' defaults write com.apple.finder 'AppleShowAllExtensions' $' @@ -329,6 +339,11 @@ defaults write com.apple.finder 'FXPreferredViewStyle' $' Flwv ' +defaults write com.apple.finder 'FXRemoveOldTrashItems' $' + + + +' defaults write com.apple.finder 'NewWindowTarget' $' @@ -344,11 +359,31 @@ defaults write com.apple.finder 'QuitMenuItem' $' ' +defaults write com.apple.finder 'ShowExternalHardDrivesOnDesktop' $' + + + +' +defaults write com.apple.finder 'ShowHardDrivesOnDesktop' $' + + + +' +defaults write com.apple.finder 'ShowMountedServersOnDesktop' $' + + + +' defaults write com.apple.finder 'ShowPathbar' $' ' +defaults write com.apple.finder 'ShowRemovableMediaOnDesktop' $' + + + +' defaults write com.apple.finder 'ShowStatusBar' $' @@ -364,6 +399,11 @@ defaults write com.apple.finder '_FXSortFoldersFirst' $' ' +defaults write com.apple.finder '_FXSortFoldersFirstOnDesktop' $' + + + +' defaults write com.apple.HIToolbox 'AppleFnUsageType' $' @@ -371,6 +411,11 @@ defaults write com.apple.HIToolbox 'AppleFnUsageType' $'' +defaults write com.apple.screencapture 'include-date' $' + + + +' defaults write com.apple.screencapture 'location' $' diff --git a/tests/system-defaults-write.nix b/tests/system-defaults-write.nix index c5c9b754..078cf82f 100644 --- a/tests/system-defaults-write.nix +++ b/tests/system-defaults-write.nix @@ -42,6 +42,7 @@ system.defaults.NSGlobalDomain."com.apple.springing.delay" = 0.0; system.defaults.NSGlobalDomain."com.apple.swipescrolldirection" = true; system.defaults.".GlobalPreferences"."com.apple.sound.beep.sound" = "/System/Library/Sounds/Funk.aiff"; + system.defaults.menuExtraClock.FlashDateSeparators = false; system.defaults.menuExtraClock.Show24Hour = false; system.defaults.menuExtraClock.ShowDayOfWeek = true; system.defaults.menuExtraClock.ShowDate = 2; @@ -50,11 +51,13 @@ system.defaults.dock.orientation = "left"; system.defaults.dock.persistent-apps = ["MyApp.app" "Cool.app"]; system.defaults.dock.persistent-others = ["~/Documents" "~/Downloads/file.txt"]; + system.defaults.dock.scroll-to-open = false; system.defaults.finder.AppleShowAllFiles = true; system.defaults.finder.ShowStatusBar = true; system.defaults.finder.ShowPathbar = true; system.defaults.finder.FXDefaultSearchScope = "SCcf"; system.defaults.finder.FXPreferredViewStyle = "Flwv"; + system.defaults.finder.FXRemoveOldTrashItems = false; system.defaults.finder.AppleShowAllExtensions = true; system.defaults.finder.CreateDesktop = false; system.defaults.finder.NewWindowTarget = "Other"; @@ -62,9 +65,15 @@ system.defaults.finder.QuitMenuItem = true; system.defaults.finder._FXShowPosixPathInTitle = true; system.defaults.finder._FXSortFoldersFirst = true; + system.defaults.finder._FXSortFoldersFirstOnDesktop = false; system.defaults.finder.FXEnableExtensionChangeWarning = false; + system.defaults.finder.ShowExternalHardDrivesOnDesktop = false; + system.defaults.finder.ShowHardDrivesOnDesktop = false; + system.defaults.finder.ShowMountedServersOnDesktop = false; + system.defaults.finder.ShowRemovableMediaOnDesktop = false; system.defaults.hitoolbox.AppleFnUsageType = "Show Emoji & Symbols"; system.defaults.screencapture.location = "/tmp"; + system.defaults.screencapture.include-date = true; system.defaults.screensaver.askForPassword = true; system.defaults.screensaver.askForPasswordDelay = 5; system.defaults.smb.NetBIOSName = "IMAC-000000";