[Pythonmac-SIG] associating file types and applications...

Bob Ippolito bob at redivi.com
Thu Apr 1 12:53:00 EST 2004


On Apr 1, 2004, at 12:43 PM, Tom Pollard wrote:

> On Apr 1, 2004, at 2:38 AM, Jens Miltner wrote:
>>>> The default app to use when opening a document is a property of the  
>>>> Finder.  Users can always reassign particular document types to the  
>>>> app of their choosing using the Info window.  So, I'm not sure it  
>>>> would be considered "playing nice" to override that preference for  
>>>> an existing filetype.  I imagine if you introduce a new filetype,  
>>>> your app will automatically be the default app for opening those  
>>>> files.  That's just my impression of how things work - I'm not an  
>>>> expert.
>>>
>>> There *is* a way to do this, though: the various media players  
>>> (quicktime, itunes, realplayer, windows media) all offer to handle  
>>> all your mp3s and other types for you, and if you say "yes" they do  
>>> it (at least until you override again from the finder).
>>>
>>> I'm not sure whether they do this through AppleEvents to the Finder,  
>>> AppleEvents to something else or a completely different mechanism,  
>>> though.
>>
>> AFAIK, this is still done is through InternetConfig (even though that  
>> API is kind of deprecated) - you should be able to set the default  
>> "helper app" for a file type / mime type using the InternetConfig  
>> APIs...
>
> I don't know how to change the filetype/application association from  
> the command line, but I did find that this information is kept in the  
> LaunchServices property list  
> (~/Library/Preferences/com.apple.LaunchServices.plist).   You can  
> browse this file by opening it in with the Property List Editor.  It's  
> just an XML file, so you can open it in a text editor, too.  You can  
> dump its contents to the terminal in more readble form by saying
>
>     % defaults read com.apple.LaunchServices
>
> For simpler plists, the 'defaults' command would also let you change  
> property values from the command line, but in this case that doesn't  
> work, because 'defaults' only acts on top-level properties.   
> LaunchServices has only a single top-level property,  
> "LSPrefsBindings", a dictionary that associates filetypes with  
> application bundles.   Also, application bundles are identified using  
> more that just a path to the application, but a small dictionary of  
> information, including a binary "LSBundleLocator" that may be an  
> alias, or something like that.
>
> There are some command-line apps included with the LaunchServices  
> framework, in
>
>      
> /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ 
> LaunchServices.framework/Versions/Current
>
> but none of these looks like a tool for changing filetype/application  
> associations.
>
> I imagine poking around the Developer documentation on the ADC site  
> would reveal a programmatic way of interacting with LaunchServices to  
> change the associations...

 From what I remember, I'm pretty sure LaunchServices does NOT offer  
that functionality to the developer.  If it does, it's new with 10.3.   
The LaunchServices database is mostly a black box.

-bob




More information about the Pythonmac-SIG mailing list