Re: Defaults access
Re: Defaults access
- Subject: Re: Defaults access
- From: Joshua See <email@hidden>
- Date: Wed, 1 Oct 2003 09:12:31 -0500
On Tuesday, September 30, 2003, at 07:59 PM, Yannis Angelidis wrote:
I want to access the balance setting of the output sound.
It is in /Library/Preferences/com.apple.soundpref.plist.
So, I want to do something like this in the terminal
defaults read -g
"com.apple.soundprefs.Devices.OutputDevices.AppleDBDMAAudioDMAEngine:0.
Balan
ce" , witch is totally wrong.
1) You have have typo in the properties list name, and the sound
preferences are not in the global domain, which is limited to the
current user. There is global and then there is global.
2) When you see "domain" in the man page for defaults, think "path",
but never give the extension, defaults fills that in (commonly .plist,
rarely .xml) on its own.
3) Defaults is surprisingly limited despite its complexity. There is no
syntax for reading nested keys individually. Also, not all of the
switches listed in the documentation work in the mac version.
4) The style of output in defaults will change based on the number of
elements in the array or dictionary it is reading. Remember that when
constructing functions to do this.
All of that being said, beware of line wraps and try this:
set balance to {}
set def_read to every paragraph of (do shell script "defaults read
/Library/Preferences/com.apple.soundpref Devices")
repeat with i in def_read
if i contains "Balance" then
set the end of balance to (text from ((offset of "=" in i) + 2) to -3
of i) as real
end if
end repeat
balance
The result should be a list with the balance setting for every audio
output device, though I haven't done any significant testing.
Note that I'm not showing the syntax to set a key. Defaults has a
better set of tools for writing than for reading, but its still ugly. I
had to make several defaults reading scripts, so I have other functions
available, but nothing really beautiful. The most promising tactic I
could think of was to modify the output from defaults to be a line of
AS and do script it, but I had trouble with the quotation marks always
being escaped.
--
Sincerely,
Joshua See
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.