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](../../I/static/images/bd37838064d675d7e2531b994c0fb1373946a15c09c0f643a009aa09b5828f71.png)
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.
The official keyboard command for Spotlight is Cmd+Space. Does that work with the menu hiding script? – digitxp – 2010-12-25T04:21:49.650
No, unfortunately it doesn't. – Jack7890 – 2010-12-25T05:39:10.087