One option would be to use AppleScript:
$ osascript -e 'id of app "Finder"'
com.apple.finder
You could also do something like this:
$ bundle=$(mdfind -onlyin / kMDItemKind==Application | grep -i "/Finder.app$" | head -1)
$ defaults read "$bundle/Contents/Info" CFBundleIdentifier
com.apple.finder
Both of these are fairly slow (about 0.05-0.2s on my Air) though. Are there any faster or less hacky options?
defaults read
seems like the right way to do it (or else querying LaunchServices via Obj-C) - why do you consider 0.1s slow?osascript
solution. How many times a second do you need to run this though?