Running Mac OS X Tiger: A No-Compromise Power Users Guide to the Mac (Animal Guide)
14.2. Where Preferences Are Stored
As mentioned earlier, the defaults database stores preference data in files located in the Library/Preferences folder of a filesystem domain. For example, when a preference applies to a single user, it is written to the ~/Library/Preferences folder. If the preference applies to all users on a system, it is written to the /Library/Preferences folder. Each of the files in the defaults database takes a unique name, known as a preference domain, determined by the application that uses it. The Apple-recommended naming convention for preference domains is to use the reverse Internet domain name of an application's vendor, followed by the name of the application. For example, all the plist files used by the various Apple-supplied applications use filenames that begin with com.apple, followed by the name of the application, followed by the .plist extension. Example 14-2 shows a partial command-line listing of the ~/Library/Preferences directory for a freshly created user: Example 14-2. The ~/Library/Preferences directory
$ ls -l total 296 drwx------ 3 panic panic 102 Jun 9 20:52 ByHost drwx------ 3 panic panic 102 May 16 16:27 Explorer drwxr-xr-x 3 panic panic 102 Jun 9 20:53 Macromedia -rw-rr-- 1 panic panic 8611 Jun 9 20:52 QuickTime Preferences -rw------- 1 panic panic 234 Jun 9 21:04 com.apple.AddressBook.plist -rw------- 1 panic panic 443 May 16 16:38 com.apple.BezelServices.plist -rw------- 1 panic panic 483 Jun 9 20:52 com.apple.Bluetooth.plist -rw------- 1 panic panic 98 May 16 16:34 com.apple.HIToolbox.plist -rw------- 1 panic panic 239 May 16 16:34 com.apple.MenuBarClock.plist -rw------- 1 panic panic 1603 Jun 9 21:24 com.apple.Preview.plist -rw------- 1 panic panic 1561 Jun 9 21:31 com.apple.Safari.plist -rw------- 1 panic panic 71 Jun 9 21:22 com.apple.Syndication.plist
When you look into your own ~/Library/Preferences directory, you'll see more files than this, but by applying the naming convention rules, you should be able to easily sort out which property list file belongs to which application. Preferences are written into the Library/Preferences folder of a filesystem domain. When an application searches for the value of a preference, it can be given a value from the User, Local, Network, or System filesystem domains. This means general settings that apply to all users can be defined at the Local or Network domain level. Settings that apply to a single user are written to the User domain so that they remain separate from the preferences of other users.
14.2.1. Host-Based Preferences
Because Mac OS X can mount Home folders from a server and a user might log into several different machines with her account, the defaults database provides a mechanism for applications to store information on a per-machine basis. This allows applications, such as the one that provides iDisk synchronization, to keep distinct settings depending on which machine you are using. To keep these settings distinct, they are kept in a ByHost folder within the Library/Preferences folder. They too use a naming convention consisting of the reverse Internet domain name of the vendor, the application name, the Ethernet MAC address of the host, and then the plist file extension. Example 14-3 shows a list of the files you might find in the ByHost folder. Example 14-3. The contents of the ByHost folder
$ ls ~/Library/Preferences/ByHost RSS Visualizer.000a95a9ba2a.plist com.apple.DotMacNotifications.000a95a9ba2a.plist com.apple.HIToolbox.000a95a9ba2a.plist com.apple.ImageCapture2.000a95a9ba2a.plist com.apple.ImageCaptureExtension2.000a95a9ba2a.plist com.apple.MIDI.000a95a9ba2a.plist
14.2.2. Global Preferences
In addition to the preferences that you can see in Example 14-2, a hidden file named .GlobalPreferences.plist in the ~/Library/Preferences folder contains preferences used by all applications. It contains data that affects all applications equally, such as the locale of the system in use. Example 14-4 shows this file for a freshly created user (converted into XML format first, of course). Example 14-4. The .GlobalPreferences.plist file
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AppleAntiAliasingThreshold</key> <integer>8</integer> <key>AppleLanguages</key> <array> <string>en</string> <string>ja</string> <string>fr</string> <string>de</string> <string>es</string> <string>it</string> <string>nl</string> <string>sv</string> <string>no</string> <string>da</string> <string>fi</string> <string>pt</string> <string>zh_CN</string> <string>zh_TW</string> <string>ko</string> </array> <key>AppleLocale</key> <string>en_US</string> </dict> </plist>
These preferences correspond to some of the settings you can apply in the System Preferences application. For example, Example 14-4 shows the array of strings associated with the AppleLanguages key. The strings in the array correlate to the language packages you can choose from in the International preference panel (shown in Figure 14-1). 14.2.3. Non-Defaults-Based Preferences
Application preference files that aren't part of the defaults database can also be stored in the ~/Library/Preferences folder. These preferences tend to be written in a proprietary format and are not easily readable except through the application that wrote them. Typically, applications that write non-defaults database preferences are older Carbon-based applications that migrated to Mac OS X from Mac OS 9 and already have their own preference-handling code. These applications are truly antisocial because they can only run in Classic mode, and they write their opaque preference files into Mac OS 9's /System Folder/Preferences folder. |
Категории