How to Activate Default Browser?


I can see an option to activate the chosen browser e.g., Firefox, but is there a way for KM to activate the browser, which is currently set as a default one?


But I don't want to open any specific URl with that browser. I just want to activate / show it so that I can do if / then /that

E.g. IF default browser is Opera then click here, OR if default browser is Chrome click elsewhere

You don't need to activate or open the default browser in order to determine which browser it is.
This Swift script by @Tom returns the default browser as text:

ACTION: Get Current Default Browser

Example Output

Download ACTION

Execute a Swift Script.kmactions (1.9 KB)

// Author: @Tom

import Foundation

let theURLStrg = "http://"
//let appIdentifierKey = "CFBundleIdentifier" // App ID
let appIdentifierKey = "CFBundleName" // App name; CFBundleDisplayName does not always exist
let appVersionKey = "CFBundleShortVersionString" // App version

let theURL = CFURLCreateWithString(nil, theURLStrg as CFString, nil)

guard let defaultHandler = LSCopyDefaultApplicationURLForURL(theURL!, .viewer, nil) else {
    fatalError("No default handler for '\(theURLStrg)' found.")

let defaultHandlerURL = defaultHandler.takeUnretainedValue()

guard let bundleDict = CFBundleCopyInfoDictionaryForURL(defaultHandlerURL),
    let theDict = bundleDict as? [String: AnyObject] else {
        fatalError("App at URL has no info dictionary.")

guard let appIdentifier = theDict[appIdentifierKey],
    let appVersion = theDict[appVersionKey] else {
    fatalError("Keys not found in info dictionary.")

let appPath = CFURLCopyFileSystemPath(defaultHandlerURL, .cfurlposixPathStyle)

print("\(appIdentifier) (\(appVersion)),\(theURLStrg),\(appPath!)", terminator:"")

1 Like

Indeed! What I use is a command line utility: defaultbrowser made by kerma: source + usage

installation is easy:

brew install defaultbrowser

Running defaultbrowser without arguments lists available HTTP handlers and shows the current setting.

$ defaultbrowser

  • chrome

Works for me, happy coding, Happy New Year