Re: Determining the Default Mail App
Re: Determining the Default Mail App
- Subject: Re: Determining the Default Mail App
- From: Matt Deatherage <email@hidden>
- Date: Wed, 8 Feb 2006 16:58:14 -0600
On 2/7/06 at 6:20 PM, kai <email@hidden> wrote:
> on defaultApp for i
> set p to POSIX path of (path to preferences) & ¬
> "com.apple.LaunchServices.plist"
> tell application "System Events" to set i to value of ¬
> property list item "LSBundleSignature" of property list item 1 ¬
> of property list item ("U:" & i) of property list item ¬
> "LSPrefsBindings" of property list file p
> tell application "Finder" to (get name of application file id i)'s ¬
> text 1 thru -5
> end defaultApp
Since no one else has said this, I'll chime in: this is the best
approach currently available, even if it needs refinement to fix
errors.
Reading a LaunchServices.plist file yourself and trying to parse it
with grep is a classically bad idea, because the format of the file is
subject to change. In fact, in Tiger, it may be a *binary* property
list file, not an XML file at all.
Using "defaults" via shell scripting avoids this problem, but the
better way is to ask System Events to parse the file for you, because
System Events already has the code built-in to do it. System Events is
already running, too - "do shell script" will launch an invocation of a
shell and fire up all that stuff just to parse text that System Events
is happy to do for you.
I skimmed the whole thread after coming up with a similar but uglier
approach, and Kai's method is the best we have until there's real
Launch Services support in System Events. This way, the only exposure
you have is depending on the information being in
"com.apple.LaunchServices.plist" in your preferences folder, the keys
remaining largely the same, and System Events being able to read them.
The more you rely on the system parsing things, and the less you do on
your own, the more future-proof your code will be. I suspect this code
needs several "try" blocks in case the specific records of the plist
file do not exist, but other than that, it's on the right track.
--Matt (compatibility 'R' us)
--
Matt Deatherage <email@hidden>
GCSF, Incorporated <http://www.macjournals.com>
It's perfectly logical, just not in a logical way.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden