Using pyobjc-framework-CoreServices

mfcfadmin
Contributor II

Trying to write a replacement for SetDefaultMailApp which implies LaunchServices but seems to be part of CoreServices now and I've installed the python module but have no idea how to import it so I can use LSSetDefaultHandlerForURLScheme

Thanks for any Python 3.11 help.

1 ACCEPTED SOLUTION

mfcfadmin
Contributor II

Disappointed that no replies here or in Python forums so went with AppleScript application:


-- defaults write as an application to set mailto handler to Outlook

-- plist is under ~/Library/Preferences/

-- osascript -e 'id of app "Microsoft Outlook"'

-- will give you the com.microsoft.Outlook

do shell script "defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{\"LSHandlerPreferredVersions\" = { \"LSHandlerRoleAll\" = \"-\"; };LSHandlerURLScheme=mailto;LSHandlerRoleAll=com.microsoft.Outlook;}'"

display dialog "Reboot required to take effect" buttons {"OK"} default button "OK"


 

View solution in original post

1 REPLY 1

mfcfadmin
Contributor II

Disappointed that no replies here or in Python forums so went with AppleScript application:


-- defaults write as an application to set mailto handler to Outlook

-- plist is under ~/Library/Preferences/

-- osascript -e 'id of app "Microsoft Outlook"'

-- will give you the com.microsoft.Outlook

do shell script "defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{\"LSHandlerPreferredVersions\" = { \"LSHandlerRoleAll\" = \"-\"; };LSHandlerURLScheme=mailto;LSHandlerRoleAll=com.microsoft.Outlook;}'"

display dialog "Reboot required to take effect" buttons {"OK"} default button "OK"