I’m not a scripter so I came here, unsuccessfully so far, looking for a script to switch default browsers. Specifically to switch between Camino for general use and Omniweb for downloading selected text in rtf which Camino can’t yet handle.
So far I’m using a script I found which will load the page shown in Camino into Omniweb but that isn’t quite as convenient as being able to transparently switch defaults according to priority, via a Quicksilver trigger - ie. the script would ‘if and but’ around whichever browser is set as default and switch to the other. Who knows? It might help other researchers too, but I haven’t yet found anything like it.
Any pointers, or examples? Much appreciated if there are. Thanks.
A search for default browser would have included this hit from this forum
Try this simple script with several default browsers listed. It should tell you what the default browser is set to, but isn’t bombproof; doesn’t work for all configurations and returns a preference file name.
try
do shell script "defaults read com.apple.LaunchServices | grep 'http;' | cut -d \\\" -f 2"
set defaultBrowser to result
on error -- if not listed, then the system default
set defaultBrowser to "com.apple.safari"
end try
Alternatively, this handler by Kai will return the path to and name of the default browser no matter what:
set {browserPath, browserName} to getDefaultBrowserInfo()
to GetDefaultBrowserInfo()
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"
set {defBrowserName, browserContainerAlias} to ¬
{name, container} of application file id creatorType
end tell
return {((browserContainerAlias as Unicode text) & defBrowserName), defBrowserName}
end GetDefaultBrowserInfo
Since you make reference to a script that will “decide” which browser is appropriate beforehand, you don’t have to know the default, just tell the one you want to open the URL you have as a variable - you don’t have to switch the default to force a URL to open in a different browser.