Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X 10.10.1: Setting a new default browser failed #2

Closed
morgrowe opened this issue Jan 12, 2015 · 8 comments
Closed

OS X 10.10.1: Setting a new default browser failed #2

morgrowe opened this issue Jan 12, 2015 · 8 comments

Comments

@morgrowe
Copy link

I was trying to get around the new and annoying "Do you want to keep your default browser 'x' or keep using 'x'?" dialog window that was introduced in OS X Yosemite:

example

When I execute the following command "defaultbrowser -set safari" or "defaultbrowser -set chrome", I get this error along with the pictured dialog box:

Setting a new default browser failed

Do you know if your tool will be able to bypass the new dialog window at some point?

Thanks,
Morgan

@kerma
Copy link
Owner

kerma commented Jan 12, 2015

I'll look into it, but the same dialog appears when you change your default browser from Chrome/Safari/Firefox settings. Seems it's something Yosemite forces on you. There might be some hack to get around that, but I don't think Apple really supports suppressing that dialog.

However, I should be able to fix the program error when you make a choice on the dialog. Failing to set the new browser makes the thing useless in the first place. Thanks for reporting.

Some background information mostly for myself: https://bugzilla.mozilla.org/show_bug.cgi?id=1063529

@morgrowe
Copy link
Author

Yes, like you said, it seems to be a new 'feature' in Yosemite. I understand why they're doing it, but I hope Apple allows you to suppress it programatically.

I didn't say it in my original post, but although your tool says it has failed, after you make a choice using the dialog window, it does set the default browser successfully. Just a shame I have to interact with the dialog.

Thanks for investing the time into looking into this issue. If you'd like me to do any testing, please let me know.

@kerma
Copy link
Owner

kerma commented Apr 7, 2015

I removed the code that wasn't working on 10.10, so it doesn't lie anymore. Unfortunately I haven't found a solution to supress the alert message.

Maybe someone in SO comes up with something: http://stackoverflow.com/questions/29500776/how-to-suppress-launch-services-alert-message-on-os-x-10-10

@shazoom
Copy link

shazoom commented Apr 30, 2015

I've written some applescript which can alleviate this problem. Here are
the relevant bits:

-- Rather than use a global to store the path I used a function to return
-- as globals don't work when you import the script. I expect there are
-- better ways but this is simple. 
on get_defaultbrowser_path()
    return POSIX path of ((path to home folder as text) & "bin:defaultbrowser")
end get_defaultbrowser_path


-- The delay here may not be necessary at all, at least most of the time.
on change_default_browser(browser)
    set m_path to get_defaultbrowser_path()
    set shell_cmd to (m_path & " -set " & browser)
    do shell script shell_cmd
    tell application "System Events"
        delay 0.2
        keystroke tab
        keystroke space
    end tell
end change_default_browser

Now, use this in a script like this:

set lib_filename to "my_lib.scpt"
-- Provide whatever path makes sense. In this case we are looking for
-- the library in the in the same directory as the calling script; this
-- script.
set my_lib to load script (POSIX path of ((path to me as text) & "::" & lib_filename))
change_default_browser("Chrome") of my_lib

@casares-dev
Copy link

casares-dev commented Oct 16, 2016

I tried using this script but the pop-up is not focused when the script is run. Is there a way to call it to focus from the script? I know ways exist to do this if the window has a title, but the pop-up does not. Trying this on macOS Sierra.

@shazoom
Copy link

shazoom commented Oct 16, 2016

You're right. It doesn't get focus anymore on sierra, it doesn't work for me either.

@ITler
Copy link

ITler commented Jul 7, 2017

Situation didn't change here, yet?

@kerma
Copy link
Owner

kerma commented Oct 18, 2020

Closing. Same issue is discussed in: #3

@kerma kerma closed this as completed Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants