How do I hide the Spotlight icon on Yosemite, but keep the Spotlight functionality? I use Spotlight in OS X, and I have long disliked its attachment to the menu bar.

Now, in Yosemite, Spotlight shows up as an overlay in the middle of the screen when summoned, much like other launcher utilities like Quicksilver or Alfred. But the Spotlight icon is still stuck in my menubar, even though clicking it now shows a totally detached overlay.

The traditional way to disable the search icon (chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search) also disables Spotlight completely. I want to keep Spotlight functionality, but kill the (now useless) menubar icon, since I can summon Spotlight with Cmd+Space.

I've also tried Bartender, which works but is both pricey ($15 to remove an icon!) and quirky (it takes a while to startup, so my menu bar ends up shifting around for up to a minute after logging in)

What's the best way to remove the Spotlight icon?
So I got fed up with this and decided to fix it the hard way.

I found out where Spotlight initializes the status bar item, and I just patched the status bar size to zero. This requires editing the Spotlight binary. (Note that Search.bundle is just the little stub that gets loaded into SystemUIServer to allow Spotlight.app to control the status bar).

You'll have to use the Terminal to execute some commands.

For OS X 10.10 (Yosemite):

cd /System/Library/CoreServices/Spotlight.app/Contents/MacOS
sudo cp Spotlight Spotlight.bak
sudo perl -pi -e 's|(\x48\xb8\x00\x00\x00\x00\x00\x00)\x42\x40(\x48\x89\x47\x10\x48\xB8\x00\x00\x00\x00\x00\x00\x36\x40)|$1\x00\x00$2|sg' Spotlight
cmp -l Spotlight Spotlight.bak 
sudo codesign -f -s - Spotlight
sudo killall Spotlight


For OS X 10.11 (El Capitan):

cd /System/Library/CoreServices/Spotlight.app/Contents/MacOS
sudo cp Spotlight Spotlight.bak
sudo perl -pi -e 's|(\x00\x00\x00\x00\x00\x00\x47\x40\x00\x00\x00\x00\x00\x00)\x42\x40(\x00\x00\x80\x3f\x00\x00\x70\x42)|$1\x00\x00$2|sg' Spotlight
cmp -l Spotlight Spotlight.bak 
sudo codesign -f -s - Spotlight
sudo killall Spotlight


The cmp -l line should print out something like the following:

248855   0 102
248856   0 100


If it prints out nothing, then the patch failed. I have tested this on OS X 10.10.3 (Yosemite) and OS X 10.11.5 (El Capitan; SIP off).

What this patch is doing is replacing the status bar width value (36.0, or 0000000000004240 in floating-point hex) with zero, so that when the status bar item is loaded it simply renders with a width of zero, i.e. it is invisible and doesn't affect the layout of the bar.

Screenshot before doing this hack:


  


Screenshot after doing this hack:


  


Menu icon is gone but Cmd+Space continues to work.



To revert, do the following:

cd /System/Library/CoreServices/Spotlight.app/Contents/MacOS
sudo mv Spotlight.bak Spotlight
sudo killall Spotlight