0

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?

1 Answer 1

2

defaults -currentHost write com.apple.Spotlight MenuItemHidden -int 1

This works for me, and hides the spotlight icon immediately. To turn it back on, it's just:

defaults -currentHost write com.apple.Spotlight MenuItemHidden -int 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .