Yes! It doesn't work 100% of the time, but what I've been doing for my setup script is:
`defaults read > old` -> change setting in GUI -> `defaults read > new` -> `diff old new`
If nothing is there, you're out of luck, most likely. (I think I've had luck using -currentHost or maybe sudo sometimes though...) If there is something, `less new` and search for the string, then find the path to the key. Do a test read with `defaults read <domain> <item>` to see if you got the path right.
You can also copy plist files (cp -r /Library/Preferences, or wherever) and then diff those. A useful alias to convert to xml:
For mapping UI preferences to corresponding plist keys, https://github.com/catilac/plistwatch will monitor and output real-time changes. May be easier than diffing snapshots of `defaults read`.
This doesn't help with "secret" settings that aren't exposed through the UI, but can be handy for creating setup scripts.
AIUI some of them are communicated informally by Apple engineers to individuals, some of them are found by using `strings` on the binary and looking at reasonable-seeming keys, any key that actually has a UI to set it is typically found just by setting it in the UI and seeing what changed, some of this stuff may have had UI's in the past that were removed while still leaving the defaults key, some of this stuff may just write the keys into the preferences files automatically and so you can find them just by looking at what's already there, etc.
Skimming this list right now a lot of the stuff I'm seeing definitely has UI settings, so a lot of these are just useful for e.g. automating the setup of a new user.
Theoretically you could attach to a process with LLDB, and use objc swizzling to intercept calls to NSUserDefaults. However to do this, I think you would need to disable SIP. Even then i'm not sure this would work.
In practice, people probably just read user defaults and try to reverse engineer what they do.
Defaults is a tool which can read and write system and other application settings. By default it works on the system settings. One can either pass a bundle id or a path to a plist file to read and write other settings.
You can see a huge list of settings by typing „defaults read“
Per sibling comments, you run strings on binaries, find out informally from Apple engineers, or dig through settings in the System Preferences and then use `defaults` to look for changes in output.
I occasionally stumble upon such secret troves of knowledge, but I'd love to find out how these are discovered.
Is there, like, a way to intercept all `defaults`/settings reads to discover what keys are checked?