Saturday, April 26, 2008

Gcalc Update

I updated gcalc to fix an issue caused by Google changing the HTML around the Google calculator answers (they added an extra h2 tag). No biggie, but gcalc now works again. You can get the new version here.

Also, I made gcalc a (small) code.google.com project. So you can now check it out at http://code.google.com/p/uj-gcalc/.

Thursday, April 10, 2008

Locating Apps from the Command Line

The other day I needed to find the location of an application using its bundle ID. Easy, just use LaunchServices. But I needed to do this from a script. Here are a couple perl one-liners to do it.

$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'
/Applications/TextEdit.app

$ mv /Applications/TextEdit.app ~/Desktop/
$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, "com.apple.TextEdit")'
/Users/jgm/Desktop/TextEdit.app

$ mv ~/Desktop/TextEdit.app /Applications/
$ perl -MMac::Processes -e 'printf "%s\n", LSFindApplicationForInfo(undef, undef, "TextEdit.app")'
/Applications/TextEdit.app


(Yes, I know mdfind could do something similar. But it wouldn't necessarily return the one that LaunchServices thinks is the "preferred" one if there were multiple applications with the same bundle ID.)