bmisiak / overbrowsered

Open http links in the most recently used browser instead of a default.
GNU Lesser General Public License v3.0
20 stars 2 forks source link

MacOS Monterey (12.0.1) - not working #1

Open DerKoller-eu opened 2 years ago

DerKoller-eu commented 2 years ago

Hi, unfortunately Overbrowsered is not working for me in 12.0.1. The App is not available in System Preferences, General, Standard browser dropdown. If I use the App to choose Overbrowsered as default browser, overbrowser is satisfied (default http handler: me), but every link still opens with safari as safari is also still the default choice in system preferences.

I attached some screenshots, hopefully this helps. Best, David

Bildschirmfoto 2021-11-30 um 10 11 41

Bildschirmfoto 2021-11-30 um 10 11 59

bmisiak commented 2 years ago

Thanks for the report! I just got my new MacBook and I'm seeing the issue as well. Will fix asap đź‘Ť

Apple deprecated the API https://developer.apple.com/documentation/coreservices/launch_services

func LSSetDefaultHandlerForURLScheme(CFString, CFString) -> OSStatus

seemingly in favor of

NSWorkspace setDefaultApplication(at: , toOpenURLsWithScheme:)

https://stackoverflow.com/questions/26601840/making-app-default-handler-on-osx-10-10-with-sandbox-enabled

I could not find anything online about this, but if the sandbox is enabled, LSSetDefaultHandlerForURLScheme -54 will return. I'm not sure how the entitlement should be turned on to work for it, as it happens without the sandbox.

To view it in effect, prepare a new project with:

  • (zero) Application especially launching: (NSNetification *) Notification {// Default Handler CF Strings Reef Bundle ID = (CF Stringerf) CFBringing Line ([[NSBindel Main Bundle] Bundle Identifier); OSStatus result = LSSetDefaultHandlerForURLScheme (CFRT ("max"), bundle ID); If (result! = 0) {emphasis (0); }} This will work with the next turn on the sandbox with result -54, it will fail.

OSX 10.10 According to the developer forums created on Yosemite, you can not do it anymore. Sandbox - The behavior you see is expected. This is really moving, because there is no alternative API to implement this functionality, there is a lack of exiting the sandbox.

According to Apple's developer forums, you can't do this anymore in the sandbox--the behavior you are seeing is expected. It's really aggravating, because no alternative API exists to implement this functionality, short of stepping outside of the sandbox.

https://mjtsai.com/blog/2020/09/01/setting-default-url-handlers/

Now that we’re sandboxing the app, we’re losing that feature, as LSSetDefaultHandlerForURLScheme is apparently disallowed for sandboxed apps[…]

This is a good example of how the sandbox still feels half-baked. 9 years later, it’s not documented that this function doesn’t work in sandboxed apps. There’s no replacement API, e.g. that asks the user whether it’s OK to change the URL handler. The system UI for setting the preferred RSS app has been removed, so the user can’t do it manually.

Was it worth it? Was there an epidemic of URL handler changers that we’re being protected from? Apps in the Mac App Store need to be sandboxed, and if this API were enabled in the sandbox it could in theory be policed by App Review, anyway. Apps outside the Mac App Store don’t need to be sandboxed, and malware certainly isn’t, so the restriction only affects legitimate apps that are trying to do the right thing—which the restriction discourages.

bmisiak commented 2 years ago

@DerKoller-eu I released an updated version, 1.1, in the App Store. Overbrowsered seems to correctly assume the role of the default http handler, even though it's not listed in Preferences (not sure why).

Can you try going to preferences, using the dropdown to (re)select Safari or another browser, closing the preference pane and then using Overbrowsered's menu to set it as the default again? Following that, just see if clicking links opens them in the most recently used browser.

DerKoller-eu commented 2 years ago

I used it for the whole weekend, its now working fine as you described above. Thanks a lot for the quick response!