Jump to content

Set Default Browser


Recommended Posts

Posted
45 minutes ago, vitor said:

Let me save you some trouble.

 

I already started going down the rabbit hole and come up with same solution 😆

With @FireFingers21 hint I got interested again (thanks for the link!), but haven't found a way to only get actual browsers (DEVONagent checks all the boxes). But it's very close and with some heuristics reliable. 

Posted (edited)
21 hours ago, zeitlings said:

However, refactoring/ improving the sdb workflow is currently low priority for me.

 

That being said... https://transfer.archivete.am/14mf0l/Default Browser v2.0.0-DEV.alfredworkflow

 

@FireFingers21 @vitor I wonder if you could give it a spin to check whether all non-browsers are filtered out correctly on your end and none are mistakenly skipped.

 

@FireFingers21I also remembered your approach to initial background compilation and decided to integrate it 😄.

Unfortunately, the non-compiled fallback to direct execution is now rather sluggish with this version.

 

Also note the cmd+shift modifier for blacklisting applications.

Edited by zeitlings
Posted
4 hours ago, zeitlings said:

I also remembered your approach to initial background compilation and decided to integrate it 😄.

I like it. One thing to note is in doing that, you have to remember not to ship the executable when exporting the workflow, otherwise the user still has to go through settings to authorize it (In this case, I just deleted it so it would recompile). That's why I save mine to alfred_workflow_data, so I don't have to remember what should or shouldn't be in the main Workflow directory.

 

Another thing I noticed is you'll need to figure out how to handle icons. I use Velja, for which the workflow displays a blank icon. The most reliable way I found to get an app's icon is from the CFBundleIconFile key in the app's Info.plist file. Unfortunately apps aren't consistent in using a file extension in that value, for example Firefox uses "firefox.icns", but Safari just has "AppIcon" meaning you'd need to dynamically ensure you always include the .icns extension. You could also just use a generic placeholder for unrecognized icons, but showing them dynamically should totally be possible. It's not Swift, but here's a shell script I used for testing:

#!/bin/zsh --no-rcs

app=$(mdfind "kMDItemCFBundleIdentifier == 'com.apple.Safari'")
iconFile=$(defaults read "${app}/Contents/Info.plist" CFBundleIconFile)
echo "${app}/Contents/Resources/${iconFile}"

 

Everything else seems to be working well so far though, nice job!

Posted
1 hour ago, FireFingers21 said:

...not to ship the executable when exporting the workflow...

That's why I save mine to alfred_workflow_data, so I don't have to remember what should or shouldn't be in the main Workflow directory.

 

I wish there was some kind of .gitignore equivalent to prevent certain files from being exported 😅

 

1 hour ago, FireFingers21 said:

The most reliable way I found to get an app's icon is from the CFBundleIconFile key in the app's Info.plist file.

 

Another good hint! Thanks. Already implemented.

  • 2 weeks later...
Posted

It's not working for me on Mac OS 14.6, Alfred 5.5.1

Debug Show an Error, but I don't know how to deal with it :(


image.thumb.png.78b6af0c299aed2c88e6377609248d2c.png

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...