Articles index

How to change your default web browser on Big Sur

January 6 2020 by Jeff Johnson
Support this blog: StopTheMadness, Link Unshortener, Underpass, PayPal.Me

macOS 11 Big Sur has a bug that prevents some apps from appearing in the "Default web browser" menu in the General pane of System Preferences, which of course makes it difficult to set one of those apps as your default web browser.

Default web browser menu

This bug affects my own app Link Unshortener, as well a number of other apps such as Finicky and Bumper. These apps all appeared in the Default web browser menu on macOS 10.15 Catalina and earlier. I've filed a bug report with Apple, FB8950733. The rest of this blog post explains how to work around the bug and set an app as your default web browser without the System Preferences menu.

The developer API for changing your default web browser still works correctly on Big Sur. My workaround is to call that API from the python command-line tool, a technique described by my former colleague Mike Ash. (11 years ago! Wow, time flies, doesn't it?) First, however, we need some metadata about the app, namely, the app's bundle identifier. We can get this metadata with the mdls command in Terminal:

mdls "/Applications/Link Unshortener.app"

In the output, the value of kMDItemCFBundleIdentifier is the bundle identifier:

kMDItemCFBundleIdentifier = "com.underpassapp.LinkUnshortener"

Now we can use the bundle identifier to change the default web browser:

echo 'from LaunchServices import *\nLSSetDefaultHandlerForURLScheme("http", "com.underpassapp.LinkUnshortener")' | python

At that point, you should see an alert asking whether you want to change your default web browser.

Do you want to change your default web browser?

My Terminal command looks like a lot to unwrap, but it's just the one line equivalent of entering three commands in succession:

python

from LaunchServices import *

LSSetDefaultHandlerForURLScheme("http", "com.underpassapp.LinkUnshortener")

The | character is a Unix pipe, which "pipes" the output of the echo tool to the input of the python tool. The \n character inserts a newline (equivalent to pressing the return key). LSSetDefaultHandlerForURLScheme is the Apple API to change the default web browser, and LaunchServices is the name of the system framework that contains this API.

If you want to set a different app as your default web browser, use mdls to find its bundle identifier, and then substitute the bundle identifier for Link Unshortener's in the Terminal command.

It's important to keep in mind that this workaround does not fix the "Default web browser" menu in System Preferences. In fact, even after you change your default web browser to Link Unshortener, it still won't appear in the menu, which will incorrectly show Safari as the default web browser. Nonetheless, the workaround is effective. You can see this by opening a URL from Terminal with your new default web browser:

open https://www.apple.com

You can also open Safari and see that it's no longer your default web browser.

Safari

Support this blog: StopTheMadness, Link Unshortener, Underpass, PayPal.Me

Articles index