Skip to content

Instantly share code, notes, and snippets.

@Grayson
Created October 4, 2008 19:56
Show Gist options
  • Save Grayson/14798 to your computer and use it in GitHub Desktop.
Save Grayson/14798 to your computer and use it in GitHub Desktop.
Get default application for url schemes.
#!/usr/bin/env python
# usage: python getDefaultAppForURL.py 'http://' 'ftp://' 'afp://'...
from LaunchServices import LSGetApplicationForURL, kLSRolesViewer
from Foundation import NSURL
from sys import argv
for arg in argv[1:]:
url = NSURL.URLWithString_(arg)
if url == None: continue
result = LSGetApplicationForURL(url, kLSRolesViewer, None, None)
print result[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment