jwbargsten / defbro

Change the default browser in macOS (Catalina, Big Sur).
https://bargsten.org/wissen/publish-swift-app-via-homebrew/
MIT License
41 stars 3 forks source link

How to prevent macOS prompt to change browser? #5

Open rgl opened 1 year ago

rgl commented 1 year ago

How do we prevent the following macOS prompt to change browser?

image

Are we really doomed to use an applescript like in https://www.felixparadis.com/posts/how-to-set-the-default-browser-from-the-command-line-on-a-mac/#automatically-accept-the-prompt-with-applescript?

jwbargsten commented 1 year ago

I thought about this before writing defbro and I decided at that time that it is good to have this security mechanism in place. But there are options: in the app store you can find apps that allow easy switching of the browser. They install themselves as default browser and redirect the clicked URL internally to your preferred browser. I think something like https://sindresorhus.com/velja might be a good choice for this.

rgl commented 1 year ago

Does that mean that app store installed applications somehow have more privileges than other applications? If that's not the case, how can installing another app and switching the default browser to it prevent that prompt? I mean, isn't that prompt managed by some macOS "security sub-system"?

PS: FWIW, I'm trying to automate macOS installation using ansible, but this seems to be quite painful, so currently I have to manually grant the required permissions at the macOS desktop UI. I've made this change to my macOS playbook at https://github.com/rgl/my-macos-ansible-playbooks/commit/4932f6d033506689f1045a7e3641378eaf9bb8a3.

jwbargsten commented 1 year ago

The difference is that defbro just "switches" the browser, whereas the app I suggested "acts" as browser, takes the url and opens the desired browser, such as chrome. For macos the browser stays the same, because the browser is determined by the app settings.

rgl commented 1 year ago

But don't we need to first switch the browser to that application? If so, we are back to square one, and need to manually grant that application the required permission.

jwbargsten commented 1 year ago

Indeed. But to configure your macbook you might want to use MDM or edit ~/Library/Preferences/com.apple.LaunchServices.plist directly. This is out of scope for defbro