Apple - Where are System Preferences settings stored? Trying to script equal brightness settings for two monitors
Preference locations
Some system-wide settings are in /Library/Preferences
, and some user settings are in ~/Library/Preferences
. I say "some" because I have found settings in these locations before, but have not done an exhaustive search. Also, this is what could be called an implementation detail. It's not documented publicly by Apple, is not intended for users to manipulate directly (by editing the .plist files), and the way it works could change without warning in a future version of OS X. The fact that Apple made ~/Library
hidden by default on Lion is a good indication that the contents of this directory are not intended to be modified by typical users. So, for best results, you should modify the settings indirectly through System Preferences itself.
Having said that, I changed the brightness of my iMac running 10.7.3, then went looking for changed plist files in the directories listed above. I couldn't find anything pertaining to screen brightness.
However, I was able to use Automator to record a workflow that opens System Preferences, goes to the Displays pref pane, and adjusts the brightness slider. This may be an easier and more reliable option for you. A quick Google search indicates that automator workflows can run from the command line, but I didn't try this.
I'll also add that one of my setups is a MacBook Air with a 30" cinema display. Setting the brightness to the same percentage on both (25% for example) does not mean that the brightness matches visually. You will likely need to choose different brightness levels for each display to get them to appear equally bright.
Monitoring filesystem usage by System Preferences
EDIT: The way you can see which plist files are accessed or modified while running System Preferences is to run a command like this in Terminal:
sudo fs_usage -w | grep "System Pref" | grep plist | grep -v "Info\.plist"
This command outputs a huge list of paths and files, some of which don't exist. File updates continued logging for a few seconds after I quit the app.
If you go this route, here's what I recommend:
- Dump the list to a textfile
- Eliminate duplicate paths
- Look at the files which have been modified. Files with states such as "stat64", "open", and "getattrlist" are just being opened for reading, but files with states of "chmod" or "rename" are being modified. I saw my ~/Library/Preferences/com.apple.systempreferences.plist file get renamed with an extension of .CvkFEbo, which I believe is the system's way of performing an atomic file write (write the entire file under a different name, and if that is successful, rename it to the original filename).
Unfortunately, I still didn't turn up anything regarding a screen brightness setting persisted to disk, but I have only lightly skimmed the fs_usage results to now.
Command-line tool to control brightness
I found an article that lists source code for controlling screen brightness on OS X using the CoreGraphics framework. The article is a little over two years old, and I haven't tried it myself, but it may be useful to you. There are simple compiling instructions posted at the end.