Managing Preferences with Files


Before you tackle the managing of preferences, it's important to understand where preferences can be stored. The normal location for preferences are in a property list, or .plist, file. Although preference files can be stored in many locations, they are most commonly found in

  • ~/Library/Preferences/

  • /Library/Preferences/

  • /Network/Library/Preferences/

Property list files are generally named using the reversed form of the domain name of the software creator, followed by the application's name, and they have a .plist extension. For example, Safari's preferences are stored in com.apple.Safari.plist. Preferences that apply only to the specific computer on which they were created live in a subdirectory called ByHost and include that computer's Ethernet MAC address in the filename. This is done to allow the presence of multiple host-specific preference files in a network home directory environment.

Property list files are XML-formatted and typically store settings in key-value pairs. If you've installed the Xcode Developer Tools, you can look at any .plist file simply by double-clicking it, which will open it in Property List Editor:

You can also view .plist files from the command line in Terminal. Property list files can be in a human-readable XML plain-text format or in a binary format that Mac OS X can process more quickly. Although Mac OS X can read either format, plists are created in binary format by default. To look at a plist from the command line, you must first convert the file from binary back to a simple XML text file in the Terminal window using commands like this:

 plutil -convert xml1 ~/Library/Preferences/com.apple.Safari.plist cat ~/Library/Preferences/com.apple.Safari.plist 


When an application needs to know the value of a specific preference key, it will consult each of the preferences files until the value is obtained. This allows you to layer preference files. For example, you could create a Safari preference file at /Library/Preferences/com.apple.Safari.plist that contains only the AutoOpenSafeDownloads key with a "false" value. All new users on the system would see that new preference setting without having it affect their other Safari settings.

However, since the preference domain system uses the layered approach, users can override the preferences stored in the top-level /Library/Preferences directory with those stored in the Preferences directory inside their home folders, at ~/Library/Preferences/. Each of the user-specific preferences is stored here, including those that override the preferences set at the system level. This makes the use of preference files suitable for preconfiguring a user's environment, but not for restricting access. One example of this is the login window plist.

Opening Preference Manifests

Most of the preference keys have self-explanatory titles. However, you may not always know exactly what something does, or what the possible values for it are. New in Mac OS X v10.4 Tiger are Preference Manifest XML files that describe the possible keys and values for an application's preference file and make them available for management by Workgroup Manager

A Preference Manifest file is located within the application's bundle in the ./Contents/Resources/ subdirectory. Using Safari as an example, you can look at the Preference Manifest file from the command line:

 cat /Applications/Safari.app/Contents/Resources/com.apple.Safari.manifest/Contents/Resources/ com.apple.Safari.manifest 


Inside this file you'll see a list of each of the keys you may wish to preset for your users, along with descriptions and possible values. Here is a sample of one of those keys:

[View full width]

<dict> <key>pfm_description</key> <string>TRUE to automatically open downloaded files that are of certain well-known safe types\, such as images\, PDF and text documents\, etc.</string> <key>pfm_domain</key> <string>com.apple.Safari</string> <key>pfm_name</key> <string>AutoOpenSafeDownloads</string> <key>pfm_title</key> <string>Open Safe Downloads Automatically</string> <key>pfm_targets</key> <array> <string>user</string> <string>user-managed</string> </array> <key>pfm_default</key> <true/> <key>pfm_type</key> <string>boolean</string>


In this example, the AutoOpenSafeDownloads key defaults to being true, and is of type "boolean."

Preference Manifests don't control any settings themselves, but only describe the settings that can be managed. You'll learn later in this lesson how to use these settings through Workgroup Manager if you don't wish to modify preference files directly.

Note

Safari and the VoiceOver Utility are currently the only applications included with Mac OS X that have Preference Manifests.


More Info

For more information, consult the man pages for plist, plutil, and defaults or the following developer document: "Introduction to Runtime Configuration Guidelines" (http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig) and "Preference Manifest Files for Managed Clients Overview" (http://developer.apple.com/documentation/MacOSXServer/Conceptual/Preference_Manifest_Files).





Apple Training Series(c) Mac OS X v10. 4 System Administration Reference
Apple Training Series: Mac OS X v10.4 System Administration Reference, Volume 2
ISBN: 0321423151
EAN: 2147483647
Year: 2006
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net