Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Caleb531

macrumors 6502
Original poster
Oct 17, 2009
289
0
I am trying to create an AppleScript, which will toggle a preference in an application called Anxiety. I am doing this through the PLIST file, and when I open the file in Property List Editor, the value is a checkbox.

The code below is what I am trying. It doesn't work because the value isn't TRUE or FALSE, it's a checkbox, and I don't know how to toggle that. Any help would be greatly appreciated!

try
set toggle to do shell script "defaults read com.modelconcept.Anxiety hideOnDeactivate"
if toggle = "TRUE" then
do shell script "defaults write com.modelconcept.Anxiety hideOnDeactivate FALSE"
else
do shell script "defaults write com.modelconcept.Anxiety hideOnDeactivate TRUE"
end if
end try
 
The values aren't "TRUE" and "FALSE". Use this discovery process to learn what the values are:

1. Open the plist file in Property List Editor.
2. Make sure the checkbox is unchecked.
3. Save.
4. In Terminal, enter the command below [see Note 1].
5. Note the output as the value representing "unchecked".
6. In PList Editor, check the checkbox.
7. Save.
8. In Terminal, enter the same command again.
9. Note the output as the value representing "checked".
10. Write your AppleScript to use the values noted.

To summarize: set a known value using PList Editor (only two are possible), observe the value using the 'defaults' command, use the observed values to write your script.

Note 1:
Code:
defaults read com.modelconcept.Anxiety hideOnDeactivate
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.