Last active
January 16, 2017 11:54
-
-
Save typemytype/5fed5b08cb6c51c26747bef458ffdb76 to your computer and use it in GitHub Desktop.
set the default app by file extension in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import LaunchServices | |
| import AppKit | |
| fileExtension = "thisShouldBeACoolFile" # file extension | |
| UTI = LaunchServices.UTTypeCreatePreferredIdentifierForTag(LaunchServices.kUTTagClassFilenameExtension, fileExtension, None) | |
| r = LaunchServices.LSSetDefaultRoleHandlerForContentType(UTI, LaunchServices.kLSRolesAll, AppKit.NSBundle.mainBundle().bundleIdentifier()) | |
| if r != 0: | |
| print "oeps" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment