Section 14.4. Determining Preference Keys


14.4. Determining Preference Keys

Editing preferences in the defaults database is a chicken-and-egg problem. Without knowing the key to set a preference for, it's hard to customize an application's behavior. Setting preference keys randomly won't accomplish much except to fill your defaults database with useless data. To determine which keys can be set, you have to do a bit of research. Three methods will help you determine the preference keys an application might use:

  • Looking at the preference plist files after you've customized an application

  • Searching the Web

  • Digging into the application itself

The first of these methods is fairly self-explanatory. Simply fiddle with the various settings of the application and watch the plist file to see what changes. Once you have an idea of the ways that keys are named, you can use the defaults find command. This command searches through the defaults database and returns the preference file and data associated with any particular string. For example, if after tweaking the opacity of your Terminal windows, you searched for the string Opaque, you would find the key in the com.apple.Terminal domain, as shown in Example 14-11.

Example 14-11. Searching for a string in the defaults database
 $ defaults find Opaque Found 1 keys in domain 'com.apple.Terminal': {TerminalOpaqueness = 0.7783334; }

If other applications used keys with the string Opaque, they would also be listed.

The second of these methods is also straightforwardusing the Web. The Mac OS X Hints web site (http://www.macosxhints.com) has a wealth of information on ways to hack the defaults database. Google searches (http://www.google.com) can turn up quite a lot of useful information as well.

The third of these methods is a bit more difficult and requires looking inside the application's bundle and using the strings command. The strings command examines a binary file and prints out all the strings it finds in a binary. For example, to look inside the Dock's executable, you would use the command shown in Example 14-12.

Example 14-12. Examining a binary for preference keys
 $ strings /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock _  _dyld_mod_term_funcs _  _dyld_make_delayed_module_initializer_calls The kernel support for the dynamic linker is not present to run this program. showhidden showshadow DoesPointToFocusCursorUpdate ClientMayIgnoreEvents com.apple.finder en_US trashlabel owensdock dock .dock AppleShowAllExtensions AppleShowAllFiles notfound trashfull trashempty finder ...

The result is a large number of strings, which probably don't have anything to do with preference settings at all. But many of these strings are used as preference keys and values in the plist file. This method becomes a sleuthing game that is boring for some and immensely interesting to others.

If you locate undocumented preferences, keep in mind that they may go away or be renamed in a future version of the application, something that has been known to happen in the past (especially when clever hackers have unearthed settings that Apple would really rather keep private).




Running Mac OS X Tiger
Running Mac OS X Tiger: A No-Compromise Power Users Guide to the Mac (Animal Guide)
ISBN: 0596009135
EAN: 2147483647
Year: 2004
Pages: 166

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