targendaz2 / Mac-Set-Default-Apps

A utility to change default applications in macOS
MIT License
85 stars 10 forks source link

System Settings breaks in macOS Sonoma #17

Open popaprozac opened 10 months ago

popaprozac commented 10 months ago

Issue System Settings fails to open after setting a default app

Steps to reproduce

Symptoms After setting any app as a default app, System Settings fails to load properly. The app launches but does not display any windows and this is the View menu:

Screenshot 2023-10-19 at 2 45 15 PM

Workaround I have been able to reset the LaunchServices and open System Settings by running the following:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -all local,system,user

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -seed

The good news is the change is applied successfully so after resetting all LaunchServices System Settings open and the default app is set correctly.

popaprozac commented 10 months ago

Looks like removing the sudo command from the rebuild fixes the issue. Will submit a PR asap.

targendaz2 commented 10 months ago

@popaprozac 2 questions:

The script tries to reset the LS database as the currently signed in user or root, depending on the context. My concern is that removing sudo altogether could cause issues in certain contexts (e.g. Setup Assistant).

popaprozac commented 10 months ago

Thanks for the follow up! The package is deployed via MDM but the script is run separately via a policy. I found that removing sudo from msda when running the policy via MDM or locally (both situations with a logged in user) it runs as expected. When running locally I use sudo msda but the script run via policy omits the sudo.

mmtechconsulting commented 4 months ago

Same issue here - any ideas how to fix it? - Running the script through JAMF

alexanderharm commented 2 months ago

I suffer from the same issue.

I could fix it as mentioned by the OP by running

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -all local,system,user
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -seed

as local user (NOT root). The weird thing is that I did run it as

sudo -u localuser cmd

which is identical to what your script does... however, it seems to fail in your case for some obscure reason. So my solution is to simply run above commands at the end of my script...

targendaz2 commented 2 months ago

I'm working on v2 of this app under the jxa-v2 branch. It should resolve this issue. I don't have an ETA at this time, but I'll follow up once it's released.

popaprozac commented 2 months ago

Great thank you!