Script to switch default browsers?

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.

I hadn’t found that thread, Adam, but in any case it doesn’t get to where I’d wanted, just confirms what’s already there, afaics.

In some kind of script-speak I guess what I was looking for was approx:

set DefaultBrowser1 to “Camino”
set DefaultBrowser2 to “OmniWeb”

(these set manually by user)

if DefaultBrowser is set to DefaultBrowser1 then
set DefaultBrowser to DefaultBrowser2

else if DefaultBrowser is set to DefaultBrowser2 then
set DefaultBrowser to DefaultBrowser1

end

  • how doable/usable that is in these cases I don’t know, or how flexible such a layout might be for other browsers.

Thanks again.