How to find out what the setting you want to change is called

when you are trying to set application preferences how do you determine what the setting is called when the obvious fails?

the first works as expected but the second does not

tell application "System Events" to tell appearance preferences to set dark mode to true
tell application "System Events" to tell appearance preferences to set dark mode to auto

You look in the System Events AppleScript dictionary. The dark mode property is a boolean.

Makes sense adding AppleInterfaceStyleSwitchesAutomatically with value


hidden plist file which path is ~/Library/Preferences/.GlobalPreferences.plist

I can’t test this suggestion now, because I have to go at work.

  1. Don’t alter plist files manually as the setting probably won’t stick.
  2. Don’t don’t suggest people do anything which alters system plist files in any way at all unless you have tested it yourself and found that it does what the OP wants with no undesirable side effects.

I’m sorry, yesterday I was in a hurry to work, but now I was able to test my proposal myself. The following command:

do shell script ("defaults write .GlobalPreferences AppleInterfaceStyleSwitchesAutomatically true")

successfully adds the required key and value to the specified property list, but unfortunately System ignores this change. So makes sense only getting appearance’s auto state using defaults read command:

	do shell script ("defaults read .GlobalPreferences AppleInterfaceStyleSwitchesAutomatically")
	return true
on error number 1
	return false
end try

Unfortunately, I have not yet been able to find working solution (without using GUI scripting) to the OP’s question about how to set the auto mode.

NOTE: answering to the title of this topic: the auto constant has do nothing with general appearance settings. It is constant for use with desktop appearance…