I suspect that there may be a better programmer-oriented answer to this question. Could I recommend that you flag this post and request it to be migrated to StackOverflow?
–
Jason SalazDec 4 '11 at 23:44

@JasonSalaz This would be off-topic at Stack Overflow.
–
ؘؘؘؘDec 5 '11 at 4:49

I suppose the question I would ask first is... What method you want to use to hold of the information, and in what format. I can think of at least two ways of getting the info using AppleScript, one using the file and plist read functions, and the second using the System Preferences AppleScript interface itself. The second method could also provide a method to set the option if it is not set, however I do not believe that is possible if the security on the pane is activated. It shouldn't take long to rig up a script to do it either.
–
Stu WilsonJan 11 '12 at 23:20

I'm very tempted to edit this to make it more on-scope, but much of the comments would then seem out of place. Perhaps I can answer it to help clarify what is on-topic here and what is not.
–
bmike♦Jul 2 '12 at 14:57

3 Answers
3

The end result of the "Set Date and Time Automatically" checkbox is that the ntpd daemon gets started by launchd.

So you could check for the presence of the file /var/run/ntpd.pid or presumably check if ntpd is running as a process. This is all good and fine for the site, but your second part to the question on how to programmatically retrieve this status is basically off-topic here.

We do allow limited AppleScript, Automator, and shell scripting programming questions. The full scope of developer questions (especially with new OSX restrictions such as sandboxing) or code level Q&A on how to program are best asked on http://stackoverflow.com/ rather than here.

With that out of the way - here's the back story about why this actually a fairly complicated question. Launchd is responsible for starting and stopping ntpd time keeping daemon when you toggle that switch and rather than load or unload the configuration file for that "job", the tool instead has an internal override plist file that has a true/false status for certain jobs to be disabled even though they should normally run. When you toggle the System Preference checkbox in Date & Time, this file changes Disabled key value at the end of the file to be or when automatic timekeeping is off or on (respectively).: