Does anyone have working code that can return the default browser (applicable to mail client ect for bonus points) under 10.4?
I have been using…
on DefaultBrowser()
set creatorType to word -1 of (do shell script "defaults read com.apple.LaunchServices |grep -C5 E:html | grep -w LSBundleSignature ")
set {text:creatorType} to (text of creatorType) as text
tell application "Finder"
(application file id creatorType) as alias
end tell
end DefaultBrowser
But this method doesn’t function under tiger. I know that setting the defaults has moved to each of apple’s apps (Mail, Safari etc.) in 10.4. This is a poor decision that smells bad to me, but that’s neither here nor there. I’d love to know the ins and outs of Apple’s current method for determining the appropriate app to launch for all types if someone has a handle on it.
Model: MBP C2D 2.33
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
on DefaultBrowser()
try
set creatorType to (do shell script "defaults read com.apple.LaunchServices | grep html")
set {TID, text item delimiters} to {text item delimiters, quote}
set creatorType to text item 4 of creatorType
set text item delimiters to TID
on error
set creatorType to "com.apple.safari" -- if the browser has never been changed, there is no entry
end try
tell application "Finder" to (application file id creatorType) as alias
end DefaultBrowser
That errors for me in the Finder block, Stefan, but this is what I use:
try
set defaultBrowser to (do shell script "defaults read com.apple.LaunchServices | grep 'http;' | cut -d \\\" -f 2")
on error -- if not listed, then the system default
set defaultBrowser to "com.apple.safari"
end try
tell application "Finder" to set DB to name of (application file id defaultBrowser)
I don’t have Tiger, but read somewhere that in Tiger the database for LaunchServices was stored there. Just thought I would mention it if someone didn’t know that and might want to check it out.
Edited: come to think of it, maybe it was in the local /Library/Caches/.
You’re right, kel, in /Library/Caches there are a few cache files of launch services ,
but they don’t contain the information of the default browser.
Parsing the com.apple.LaunchServices.plist is the right way to get it