Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used this tip top hide my menu bar in a bunch of applications, which is a great way to get more free screen space. The one downside is that (for inexplicable reasons) it disables Spotlight when I'm in those applications--e.g. even if I hover over the menu bar to make it appear, clicking on the Spotlight icon does nothing.

I have a plan to work around this: I'd like to launch Spotlight using QuicKeys, which lets you run terminal commands using keyboard shortcuts. But to do that, I need to know how to launch Spotlight with a terminal command. Does anyone know how to do this?

I'm on OS X 10.6.

share|improve this question
    
The official keyboard command for Spotlight is Cmd+Space. Does that work with the menu hiding script? –  digitxp Dec 25 '10 at 4:21
    
No, unfortunately it doesn't. –  Jack7890 Dec 25 '10 at 5:39

2 Answers 2

up vote 3 down vote accepted

You can use the command-line program mdfind as a complete substitution for the Spotlight GUI. Accessing results is a bit inconvenient, though.


You can, using a little GUI scripting, open a Finder window, and perform a Spotlight search there.

For this to work, you need support for assistive devices in System Preferences » Universal Access and Full Keyboard Access in System Preferences » Keyboard » Keyboard Shortcuts.

Open /Applications/Utilities/AppleScript Editor.app, and enter the following script:

on run argv # we expect program arguments
    tell application "Finder"
        activate # focus Finder
        tell application "System Events"
            keystroke "f" using command down # press Cmd-F
            keystroke (item 1 of argv) # enter the program argument into search box
            key code 36 # press enter
            key code 48 # press tab
            keystroke " " # press space
        end tell
    end tell
end run

The steps "press tab" and "press space" are only necessary if you have not specified Search This Mac in Finder » Preferences » Advanced -- then we tab&select the This Mac option in the Finder search window.

Now save as Script, and execute from Terminal like this:

osascript spotlight.scpt test

What happens then looks somewhat like this:

alt text


The "Spotlight" action for Automator is probably not a good idea, since it runs until all results are available. Combined with Reveal Finder Items is a great way to see what opening 10,000 Finder windows looks like.


Other options, as always, are using applications such as LaunchBar, Alfred or Butler to initiate Spotlight search or provide an alternative UI.

share|improve this answer

From the Spotlight manual :

There are no configurations to Spotlight, and users should not run manually.

Guess that explains it all.

share|improve this answer
    
It refers to the Spotlight GUI process. Not Spotlight more broadly. There is e.g. the mdfind command-line application. –  Daniel Beck Dec 25 '10 at 17:45
    
And the author asks for the Spotlight "GUI" –  ismail Dec 25 '10 at 22:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.