Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited title
Link
Hugh
  • 363
  • 2
  • 10

Cannot remove spotlight item from menu bar with `defaults`

added 24 characters in body
Source Link
Hugh
  • 363
  • 2
  • 10

When unchecking "Show in Menu Bar" in System Preferences > Dock & Menu Bar > Spotlight, it removes the NSStatusItem Visible Item-0 from com.apple.Spotlight.plist. When enabling the setting, it sets this key to true.

It can be easily verified by using defaults read com.apple.Spotlight before and after unchecking the setting.

I'm trying to automate this in a macOS install script. The problem is that deleting the key with defaults delete or setting the value to false doesn't work. After doing killall SpotlightSpotlight; killall SystemUIServer or rebooting the system, it sets back the value to 1.

My guess was that some other files are modified when changing the setting with the GUI, so I tried this:

defaults read > before
# Manually change the setting in system preferences
defaults read > after
diff before > after

which outputs:

60c60
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
62c62
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
5357,5359c5357,5358
<         "NSStatusItem Visible Item-0" = 1;
<         SPMessageTracingWindowHideCount = 149;
<         SPMessageTracingWindowShowCount = 149;
---
>         SPMessageTracingWindowHideCount = 150;
>         SPMessageTracingWindowShowCount = 150;
5361c5360
<         "engagementCount-com.apple.Spotlight" = 87;
---
>         "engagementCount-com.apple.Spotlight" = 88;
9998c9997
<                 Age = "42540.278567375";
---
>                 Age = "42551.38625458333";
10050a10050
>                         352,

Maybe a file outside of the scope of defaults is modified?

When unchecking "Show in Menu Bar" in System Preferences > Dock & Menu Bar > Spotlight, it removes the NSStatusItem Visible Item-0 from com.apple.Spotlight.plist. When enabling the setting, it sets this key to true.

It can be easily verified by using defaults read com.apple.Spotlight before and after unchecking the setting.

I'm trying to automate this in a macOS install script. The problem is that deleting the key with defaults delete or setting the value to false doesn't work. After doing killall Spotlight or rebooting the system, it sets back the value to 1.

My guess was that some other files are modified when changing the setting with the GUI, so I tried this:

defaults read > before
# Manually change the setting in system preferences
defaults read > after
diff before > after

which outputs:

60c60
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
62c62
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
5357,5359c5357,5358
<         "NSStatusItem Visible Item-0" = 1;
<         SPMessageTracingWindowHideCount = 149;
<         SPMessageTracingWindowShowCount = 149;
---
>         SPMessageTracingWindowHideCount = 150;
>         SPMessageTracingWindowShowCount = 150;
5361c5360
<         "engagementCount-com.apple.Spotlight" = 87;
---
>         "engagementCount-com.apple.Spotlight" = 88;
9998c9997
<                 Age = "42540.278567375";
---
>                 Age = "42551.38625458333";
10050a10050
>                         352,

Maybe a file outside of the scope of defaults is modified?

When unchecking "Show in Menu Bar" in System Preferences > Dock & Menu Bar > Spotlight, it removes the NSStatusItem Visible Item-0 from com.apple.Spotlight.plist. When enabling the setting, it sets this key to true.

It can be easily verified by using defaults read com.apple.Spotlight before and after unchecking the setting.

I'm trying to automate this in a macOS install script. The problem is that deleting the key with defaults delete or setting the value to false doesn't work. After doing killall Spotlight; killall SystemUIServer or rebooting the system, it sets back the value to 1.

My guess was that some other files are modified when changing the setting with the GUI, so I tried this:

defaults read > before
# Manually change the setting in system preferences
defaults read > after
diff before > after

which outputs:

60c60
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
62c62
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
5357,5359c5357,5358
<         "NSStatusItem Visible Item-0" = 1;
<         SPMessageTracingWindowHideCount = 149;
<         SPMessageTracingWindowShowCount = 149;
---
>         SPMessageTracingWindowHideCount = 150;
>         SPMessageTracingWindowShowCount = 150;
5361c5360
<         "engagementCount-com.apple.Spotlight" = 87;
---
>         "engagementCount-com.apple.Spotlight" = 88;
9998c9997
<                 Age = "42540.278567375";
---
>                 Age = "42551.38625458333";
10050a10050
>                         352,

Maybe a file outside of the scope of defaults is modified?

Source Link
Hugh
  • 363
  • 2
  • 10

Cannot remove spotlight item with `defaults`

When unchecking "Show in Menu Bar" in System Preferences > Dock & Menu Bar > Spotlight, it removes the NSStatusItem Visible Item-0 from com.apple.Spotlight.plist. When enabling the setting, it sets this key to true.

It can be easily verified by using defaults read com.apple.Spotlight before and after unchecking the setting.

I'm trying to automate this in a macOS install script. The problem is that deleting the key with defaults delete or setting the value to false doesn't work. After doing killall Spotlight or rebooting the system, it sets back the value to 1.

My guess was that some other files are modified when changing the setting with the GUI, so I tried this:

defaults read > before
# Manually change the setting in system preferences
defaults read > after
diff before > after

which outputs:

60c60
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
62c62
<         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:35 +0000";
---
>         "_DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate" = "2021-03-27 06:57:49 +0000";
5357,5359c5357,5358
<         "NSStatusItem Visible Item-0" = 1;
<         SPMessageTracingWindowHideCount = 149;
<         SPMessageTracingWindowShowCount = 149;
---
>         SPMessageTracingWindowHideCount = 150;
>         SPMessageTracingWindowShowCount = 150;
5361c5360
<         "engagementCount-com.apple.Spotlight" = 87;
---
>         "engagementCount-com.apple.Spotlight" = 88;
9998c9997
<                 Age = "42540.278567375";
---
>                 Age = "42551.38625458333";
10050a10050
>                         352,

Maybe a file outside of the scope of defaults is modified?