I’m getting really hooked on LaunchBar. So much so that I want to push as many keyboard commands as possible through the versatile launcher.
Google Desktop was bollocksing up things though with its too similar keyboard trigger. Not to mention the goofiness of showing Web results ahead of desktop results. When I go to my desktop search engine I’m looking for desktop results.
At first I thought a simple LaunchBar search template would do the trick except for a couple of issues:
-
Google Desktop can be reached in a browser through a URL. Unfortunately the base of this URL has an embedded token whose creation isn’t documented anywhere.
-
Firefox is completely braindead when it comes to the Apple OpenScripting Architecture.
-
Getting LaunchBar to recognize your custom scripts and actions is a little tricky.
Mac OS X command line to the rescue.
The Google Desktop url can be pulled out of Apple’s system configuration variables using defaults
. Firefox can be told to launch a URL using the open
command. A Python script ties it all together by running the command to get the url, escaping the query args, creating the full url, and launching Firefox. Plop the script into ~/Library/Application Support/LaunchBar/Actions
and I’m in hotkey heaven.
It’s not the fastest thing in the world, but it gets the right results in the right place. Not bad for a 1 hour hack, although it took a couple of hours of research. Here’s the script:
!/usr/bin/python
import urllib
import subprocess
DEFAULTS_CMD =
‘defaults read com.google.Desktop.WebServer search_url’
def main(qargs):
output = subprocess.Popen(DEFAULTS_CMD, shell=True,
stdout=subprocess.PIPE).stdout
gdesktop_url = output.readline().strip()
url_txt = gdesktop_url + “&q=” + \
urllib.quote_plus(” “.join(args))
subprocess.check_call([“open”, url_txt])
if name == ‘main‘:
from optparse import OptionParser
op = OptionParser()
options, args = op.parse_args()
main(args)
Now to write that Discogs.Com search template for LaunchBar.