Start only safari with an url

Mac OSX specific forum
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Start only safari with an url

Post by infratec »

Hi,

Safari is not the default browser.
When I use

Code: Select all

open -a Safari https://www.google.com
The page is open twice.
First with the default browser, second with safari.
I also tried -b com.apple.Safari, but with the same result.
I also tried a scipt with tell application "Safari" but also the same.
And I'm not able to start it via /Applications/Safari.app/... because it does not accept parameters.

Is there a way via Cocoa messages to start explicit Safari with arguments?
User avatar
deseven
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Jan 12, 2011 3:48 pm
Location: Serbia
Contact:

Re: Start only safari with an url

Post by deseven »

There is a bug in macOS that was introduced in Catalina I think. Right now there is no solid way to launch only Safari with the requested URL when you have a different default browser.

It works however when Safari is already running, so you can try something hacky like

Code: Select all

open -a Safari

# wait for it to actually load

osascript -e 'tell application "Safari" to open location "https://google.com"'
But honestly I would avoid that.
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Re: Start only safari with an url

Post by Wolfram »

Code: Select all

RunProgram("open", "-a Safari https://www.google.com", "")
macOS Catalina 10.15.7
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Start only safari with an url

Post by infratec »

@Wolfram :wink:
This was the first thing I tried.

But up to now I'm not able to open Safari alone.
The default browser opens too.

I know that this is a bug of macOS since Catalina and it was solved in one version, but then come back and was never solved again.

Horrible.

I hoped on a Cocoa solution for this, but I'm not an Apple user and so I'm a bit lost.
Wolfram
Enthusiast
Enthusiast
Posts: 568
Joined: Thu May 30, 2013 4:39 pm

Re: Start only safari with an url

Post by Wolfram »

I'm on Catalina (10.15.7) too. It works as expected.

Code: Select all

RunProgram("open", "-a firefox https://www.google.com", "")
This will open Firefox only. I never got the problem that a second program was started.
macOS Catalina 10.15.7
infratec
Always Here
Always Here
Posts: 6883
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Start only safari with an url

Post by infratec »

I can not find the link to the article about that, but I found a posting where the same thing happens on 12.1


Look at the answer of user Wumms and the reply of an other user:
https://apple.stackexchange.com/questio ... ic-browser

It happens if Safari is not the default browser and you want to open a page with Safari via

Code: Select all

open -a Safari https://www.purebasic.fr/english
Post Reply