Skip to content

Commit

Permalink
Spotligh: move from controlcenter to separate module
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamanaws committed Feb 21, 2025
1 parent 20d05f8 commit 2362651
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
1 change: 1 addition & 0 deletions modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
./system/applications.nix
./system/defaults-write.nix
./system/defaults/controlcenter.nix
./system/defaults/Spotlight.nix
./system/defaults/LaunchServices.nix
./system/defaults/NSGlobalDomain.nix
./system/defaults/GlobalPreferences.nix
Expand Down
3 changes: 3 additions & 0 deletions modules/system/defaults-write.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let
ActivityMonitor = defaultsToList "com.apple.ActivityMonitor" cfg.ActivityMonitor;
WindowManager = defaultsToList "com.apple.WindowManager" cfg.WindowManager;
controlcenter = defaultsToList "~/Library/Preferences/ByHost/com.apple.controlcenter" cfg.controlcenter;
Spotlight = defaultsToList "~/Library/Preferences/ByHost/com.apple.Spotlight" cfg.Spotlight;
CustomUserPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomUserPreferences);
CustomSystemPreferences = flatten (mapAttrsToList (name: value: defaultsToList name value) cfg.CustomSystemPreferences);

Expand Down Expand Up @@ -95,6 +96,7 @@ in
CustomUserPreferences
WindowManager
controlcenter
Spotlight
]
''
# Set defaults
Expand All @@ -120,6 +122,7 @@ in
${concatStringsSep "\n" CustomUserPreferences}
${concatStringsSep "\n" WindowManager}
${concatStringsSep "\n" controlcenter}
${concatStringsSep "\n" Spotlight}
${optionalString (length dock > 0) ''
# Only restart Dock if current user is logged in
Expand Down
18 changes: 18 additions & 0 deletions modules/system/defaults/Spotlight.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ config, lib, ... }:

{
options = {
system.defaults.Spotlight.MenuItemHidden = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Menu Bar Only > Spotlight
Show Spotlight in menu bar. Default is null.
false - "Don't Show in Menu Bar"
true - "Show in Menu Bar"
'';
};
};
}
13 changes: 0 additions & 13 deletions modules/system/defaults/controlcenter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,6 @@ in
'';
};

system.defaults.controlcenter.Spotlight = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
description = ''
Apple menu > System Preferences > Control Center > Menu Bar Only > Spotlight
Show Spotlight in menu bar. Default is null.
false - "Don't Show in Menu Bar"
true - "Show in Menu Bar"
'';
};

system.defaults.controlcenter.StageManager = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
Expand Down
11 changes: 5 additions & 6 deletions tests/fixtures/system-defaults-write/activate-user.txt
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,6 @@ defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'Sound' $'<?
<plist version="1.0">
<integer>8</integer>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.Spotlight 'MenuItemHidden' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<true/>
</plist>'
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'StageManager' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
Expand All @@ -698,4 +693,8 @@ defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter 'WiFi' $'<?x
<plist version="1.0">
<integer>18</integer>
</plist>'

defaults write ~/Library/Preferences/ByHost/com.apple.Spotlight 'MenuItemHidden' $'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<true/>
</plist>'
2 changes: 1 addition & 1 deletion tests/system-defaults-write.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@
system.defaults.controlcenter.NowPlaying = "always";
system.defaults.controlcenter.ScreenMirroring = "whenActive";
system.defaults.controlcenter.Sound = "whenActive";
system.defaults.controlcenter.Spotlight = true;
system.defaults.controlcenter.StageManager = true;
system.defaults.controlcenter.UserSwitcher = "both";
system.defaults.controlcenter.WiFi = true;
system.defaults.Spotlight.MenuItemHidden = true;
test = lib.strings.concatMapStringsSep "\n"
(x: ''
echo >&2 "checking defaults write in /${x}"
Expand Down

0 comments on commit 2362651

Please sign in to comment.