Page 1 of 1
Start only safari with an url
Posted: Wed Apr 27, 2022 10:00 am
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?
Re: Start only safari with an url
Posted: Wed Apr 27, 2022 12:16 pm
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.
Re: Start only safari with an url
Posted: Wed Apr 27, 2022 5:48 pm
by Wolfram
Code: Select all
RunProgram("open", "-a Safari https://www.google.com", "")
Re: Start only safari with an url
Posted: Thu Apr 28, 2022 6:59 am
by infratec
@Wolfram
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.
Re: Start only safari with an url
Posted: Thu Apr 28, 2022 5:13 pm
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.
Re: Start only safari with an url
Posted: Fri Apr 29, 2022 7:36 am
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