I don’t seem to be able to find the combination of shell script commands for reading a .plist file in /Users/theUser/Library/Preferences/. I can get the path to it with “POSIX path of (path to Library Folder from user domain)”, but that is not a “defaults read”-able file apparently. How do I read it other than opening it for access from an AppleScript?
Hi Adam,
Unless I’m missing something, doing it as a defaults read works for me. eg:
do shell script "defaults read com.apple.ical"
John M
Thanks, John. As usual, I was simply making it too complicated - using a full path and the full name of the file including its extension, eg:
set PP to POSIX path of (path to library folder from user domain)
do shell script "defaults read " & PP & "/Preferences/com.apple.iCal.plist"
which tells me the file doesn’t exist. Obviously, defaults read doesn’t want the bumpf since the simple file name works. I was confused because, for example, to get details from the windowserver pref I had to use:
do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w -m 2 Height"
and that doesn’t work without the path (but no extension).
Where does one find the rules for this?
Hi Adam,
Have a look at the man pages for defaults there are lots of options.
If you want a list of the defaults files for the current user, you can do:
do shell script "defaults domains"
If you are looking for the contents of a particular key in a .plist file, you can access it in the command.
do shell script "defaults read com.apple.iCal CALLastSystemTimeZoneKey"
You can also use the -app flag if you just have the application name:
do shell script "defaults read -app iCal"
Best wishes
John M
Thanks, John;
It hadn’t occurred to me there was a defaults man page. Should have looked.
Adam