Jump to content

Need help generating list of browsers


Recommended Posts

Hi all

 

I am working on correcting some issues in a workflow I have and while I was in there tinkering I thought that I would try to divorce the workflow from Safari.

 

I found a command line call that will read the default browser and return it but I want to get a lot of data to make sure that I have as many browsers covered.

 

The command is:

 

defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure | awk -F'"' '/http;/{print window[(NR)-1]}{window[NR]=$2}'

 

If you are running something other than Safari could you run this command and then paste the return here so I can gather as many browser IDs as possible?

 

Or if someone knows of where there is a list of these apps?

 

Thanks

 

 

 

 

Link to comment

That’s the bundle identifier of the app. You can get it for any app by running mdls -raw -name kMDItemCFBundleIdentifier /PATH/TO/APP, so by downloading them you’ll get what you seek without even having to take them out of the DMG. Alternative versions of browsers usually have predictable bundle identifiers. So the stable version of Brave is com.brave.Browser and the beta is com.brave.Browser.beta. Edge is com.microsoft.edgemac and the canary version is com.microsoft.edgemac.Canary. Vivaldi is com.vivaldi.Vivaldi. Chrome is com.google.Chrome and the canary version is com.google.Chrome.canary.

Link to comment
2 hours ago, vitor said:

That’s the bundle identifier of the app. You can get it for any app by running mdls -raw -name kMDItemCFBundleIdentifier /PATH/TO/APP

 

I just wrote a quick Universal Action to run that for me. Thanks

Link to comment

 

So I built a series of actions that I am going to add to my Create Obsidian Bookmark action. I will be using it as a prefab in that action. 

 

Currently it has a keyword trigger but that was just for testing. It runs a shell script to get the default browser's bundle ID.

 

duti -x .html | sed -n '3p' | tr -d '\n'

 

This uses duti to get the default app for .html files. That returns three lines of data 

 

Safari
/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app
com.apple.Safari

 

I only need the last one so I use `sed` to get that and then `tr` to strip off the trailing line feed. This is split and then I save the last item as the browser name and use a conditional to select the appropriate Automation Task for each browser. 

 

I've tested it in Chrome, Vivaldi, Brave, Edge, Safari and Opera and it correctly tries to get the tab title and URL. 

 

Anyone interested in this? @vitor can I export a prefab?

 

CleanShot2023-05-03at21_07_34.jpg.35e360fd43e4e9450ba5af1099a2ef3b.jpg

Link to comment

Instead of grabbing the default browser, I would recommend grabbing the frontmost app and then acting accordingly if it is a supported browser. You can’t really trust that the default app to open HTML files will be a web browser (think web developer using a code editor).

 

I do think there could be improvements to this multiple browser handling. I have some ideas but nothing to share yet.

Link to comment
8 hours ago, vitor said:

Instead of grabbing the default browser, I would recommend grabbing the frontmost app and then acting accordingly

 

I actually thought that it might be more likely that someone would have multiple browsers open and so in that case using the frontmost app makes more sense

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...