RE: Plan E from Outer Space
RE: Plan E from Outer Space
- Subject: RE: Plan E from Outer Space
- From: Scott Babcock <email@hidden>
- Date: Wed, 17 Jun 2009 14:13:22 -0700
- Acceptlanguage: en-US
- Thread-topic: Plan E from Outer Space
You may want to check out the 'PlistBuddy' utility as an alternative to 'defaults'. The 'defaults' utility is extremely weak at dealing with anything other than simple values in root-level keys. 'PlistBuddy' has a comparatively rich set of capabilities. This is an Apple utility that gets included with every updater they've shipped since at least the Mac OS X 10.2 (Jaguar) days, and it looks like they're finally going to include it in the standard distribution in Snow Leopard. I don't know how 'PlistBuddy' interacts with the specified plist. If it uses NSUserDefaults, you should be able to modify settings of active applications. Otherwise, you'll need to make sure the application isn't running when you're making your changes.
-----Original Message-----
Date: Wed, 17 Jun 2009 10:54:43 -0500
From: Luther Fuller <email@hidden>
Subject: Re: Plan E from Outer Space
To: Applescript Users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
On Jun 17, 2009, at 10:25 AM, Matt Neuburg wrote:
> On Tue, 16 Jun 2009 12:55:45 -0500, Luther Fuller
> <email@hidden>
> said:
>> I'm going with Plan C, at least for the present
>
> You should never touch a preference .plist file directly. User
> preferences
> are maintained in memory, and the application will write them in and
> write
> them out when it pleases. If you change the plist file directly, your
> changes can be overwritten by the application when it writes out the
> preferences. The correct approach is to communicate directly with the
> defaults system using the shell "defaults" command. m.
I considered using 'defaults', but after reading its man page, it
seemed that it did exactly what I was doing in System Events (reading
& writing the preference file), but was harder to write the code.
My script checks 3 of Mail's preferences and if properly set,
continues with other business. If these preferences are not properly
set, the snippet I presented yesterday begins by quitting Mail, writes
the preference file, then ends by activating Mail. Writing to the
preference file while Mail is not running prevents overwriting.
Yes, the user can change these preferences, but my script will correct
the change next time it is run and a dialog notifies the user of this
change. Every time.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden