Managing System Services

 < Day Day Up > 

Managing User Preferences

Your preferences, located in ~/Library/Preferences are plist files, a form of XML file. In this section we will take a look at some sample plist files and learn ways to manage them. Listing 16.1 shows the Terminal.app preference file (located in ~/Library/Preferences/com.apple.Terminal.plist) from an installed, but little-used user account.

Listing 16.1. An Almost Bare Preference File for Terminal.app

 <?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>StartupFile</key>         <string></string> </dict> </plist> 

The terminal preferences currently contain little of interest other than a reference to a startup file.

NOTE

With Mac OS X 10.4, many of the plist files have been encoded into binary. To read any of these plist files, make a copy of the plist file that you are about to convert, and then run this command:

 plutil -convert xml1 <file-to-be-converted> 

If you want to convert the file back to binary, replace xml1 with binary1.


Listing 16.2 shows the Terminal.app preferences from a considerably more used account. As you can see, the plist files are not required to contain all the preferences for an application and can grow as the user specifies more preferences that aren't just the defaults. One annoyance that this causes is that sometimes hidden preferences aren't accessible through any of the application's Preferences panes. These preferences can find their way into the XML plist files only if somebody discovers their existence and adds the preference line to the plist file manually.

Listing 16.2. A Preferences File for Terminal.app That Has Accumulated Some Settings over Time

 <?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>AutoFocus</key>         <string>YES</string>         <key>Autowrap</key>         <string>YES</string>         <key>BackgroundImagePath</key>         <string></string>         <key>Backwrap</key>         <string>YES</string>         <key>Bell</key>         <string>YES</string>         <key>BlinkCursor</key>         <string>YES</string>         <key>BlinkText</key>         <string>YES</string>         <key>CleanCommands</key>         <string>rlogin;telnet;ssh;slogin</string>         <key>Columns</key>         <string>118</string>         <key>CursorShape</key>         <string>0</string>         <key>CustomTitle</key>         <string>Terminal</string>         <key>DeleteKeySendsBackspace</key>         <string>NO</string>         <key>DisableAnsiColors</key>         <string>NO</string>         <key>DoubleBold</key>         <string>YES</string>         <key>DoubleColumnsForDoubleWide</key>         <string>NO</string>         <key>DoubleWideChars</key>         <string>YES</string>         <key>EnableDragCopy</key>         <string>YES</string>         <key>ExecutionString</key>         <string></string>         <key>FontAntialiasing</key>         <string>NO</string>         <key>FontHeightSpacing</key>         <string>1</string>         <key>FontWidthSpacing</key>         <string>1</string>         <key>IsMiniaturized</key>         <string>NO</string>         <key>KeyBindings</key>         <dict>                 <key>$F708</key>                 <string>ESC[25~</string>                 <key>$F709</key> ...                 <key>~F712</key>                 <string>ESC[34~</string>         </dict>         <key>Meta</key>         <string>-1</string>         <key>NSColorPanelMode</key>         <string>6</string>         <key>NSColorPanelVisibleSwatchRows</key>         <integer>1</integer>         <key>NSFixedPitchFont</key>         <string>Monaco</string>         <key>NSFixedPitchFontSize</key>         <real>10</real>         <key>NSFontPanelPreviewHeight</key>         <real>0.0</real>         <key>NSWindow Frame Inspector</key>         <string>102 311 268 435 0 0 1024 746 </string>         <key>NSWindow Frame NSColorPanel</key>         <string>325 263 201 309 0 0 1024 746 </string>         <key>OptionClickToMoveCursor</key>         <string>NO</string> ...         <key>TermCapString</key>         <string>xterm-color</string>         <key>TerminalOpaqueness</key>         <real>1</real>         <key>TextColors</key>         <string>1.000 1.000 1.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 1.00 0 1.000 0 .000 0.000 0.000 1.000 1.000 1.000 0.667 0.667 0.667 1.000 1.000 1.000C </string>         <key>TitleBits</key>         <string>78</string>         <key>Translate</key>         <string>YES</string>         <key>UseCtrlVEscapes</key>         <string>YES</string>         <key>VisualBell</key>         <string>NO</string>         <key>WinLocULY</key>         <string>471</string>         <key>WinLocX</key>         <string>67</string>         <key>WinLocY</key>         <string>0</string>         <key>WindowCloseAction</key>         <string>1</string> </dict> </plist> 

Listing 16.3 shows a preferences file for a shareware product called GraphicConverter. As you can see in Listings 16.2 and 16.3, the items stored in the ~/Library/Preferences/ files are many and varied. You also can see that some preferences are not intuitively parseable.

NOTE

The truly observant might notice that the big block of characters in the middle of Listing 16.3 displays a vague pattern. In fact, it's an icon, encoded and stored in text form. This might give you an idea or two about how you could customize program icons automatically from a script.


Listing 16.3. The plist File for GraphicConverter

 <?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>AppleNavServices:ChooseFolder:0:HomeDirectoryPath</key>         <string>file://~/Documents/</string>         <key>AppleNavServices:ChooseFolder:0:Path</key>         <string>file://localhost/MacHD/Users/joray/Documents/</string>         <key>AppleNavServices:ChooseFolder:0:Position</key>         <data>         ATkBaA==         </data>         <key>AppleNavServices:ChooseFolder:0:Size</key>         <data>         AAAAAAFvAjA=         </data>         <key>AppleRecentFolders</key>         <array>                 <string>file://localhost/MacHD/Users/joray/Documents/</string>         </array> ...         <key>custom color table</key>         <data>         /////////////8zM/////5mZ/////2Zm/////zMz/////wAA///MzP/////MzMzM///M         zJmZ///MzGZm///MzDMz///MzAAA//+Zmf////+ZmczM//+ZmZmZ//+ZmWZm//+ZmTMz         //+ZmQAA//9mZv////9mZszM//9mZpmZ//9mZmZm//9mZjMz//9mZgAA//8zM/////8z         M8zM//8zM5mZ//8zM2Zm//8zMzMz//8zMwAA//8AAP////8AAMzM//8AAJmZ//8AAGZm         //8AADMz//8AAAAAzMz/////zMz//8zMzMz//5mZzMz//2ZmzMz//zMzzMz//wAAzMzM         zP//zMzMzMzMzMzMzJmZzMzMzGZmzMzMzDMzzMzMzAAAzMyZmf//zMyZmczMzMyZmZmZ         zMyZmWZmzMyZmTMzzMyZmQAAzMxmZv//zMxmZszMzMxmZpmZzMxmZmZmzMxmZjMzzMxm         ZgAAzMwzM///zMwzM8zMzMwzM5mZzMwzM2ZmzMwzMzMzzMwzMwAAzMwAAP//zMwAAMzM         zMwAAJmZzMwAAGZmzMwAADMzzMwAAAAAmZn/////mZn//8zMmZn//5mZmZn//2ZmmZn/         /zMzmZn//wAAmZnMzP//mZnMzMzMmZnMzJmZmZnMzGZmmZnMzDMzmZnMzAAAmZmZmf//         mZmZmczMmZmZmZmZmZmZmWZmmZmZmTMzmZmZmQAAmZlmZv//mZlmZszMmZlmZpmZmZlm         ZmZmmZlmZjMzmZlmZgAAmZkzM///mZkzM8zMmZkzM5mZmZkzM2ZmmZkzMzMzmZkzMwAA         mZkAAP//mZkAAMzMmZkAAJmZmZkAAGZmmZkAADMzmZkAAAAAZmb/////Zmb//8zMZmb/         /5mZZmb//2ZmZmb//zMzZmb//wAAZmbMzP//ZmbMzMzMZmbMzJmZZmbMzGZmZmbMzDMz         ZmbMzAAAZmaZmf//ZmaZmczMZmaZmZmZZmaZmWZmZmaZmTMzZmaZmQAAZmZmZv//ZmZm         ZszMZmZmZpmZZmZmZmZmZmZmZjMzZmZmZgAAZmYzM///ZmYzM8zMZmYzM5mZZmYzM2Zm         ZmYzMzMzZmYzMwAAZmYAAP//ZmYAAMzMZmYAAJmZZmYAAGZmZmYAADMzZmYAAAAAMzP/         ////MzP//8zMMzP//5mZMzP//2ZmMzP//zMzMzP//wAAMzPMzP//MzPMzMzMMzPMzJmZ         MzPMzGZmMzPMzDMzMzPMzAAAMzOZmf//MzOZmczMMzOZmZmZMzOZmWZmMzOZmTMzMzOZ         mQAAMzNmZv//MzNmZszMMzNmZpmZMzNmZmZmMzNmZjMzMzNmZgAAMzMzM///MzMzM8zM         MzMzM5mZMzMzM2ZmMzMzMzMzMzMzMwAAMzMAAP//MzMAAMzMMzMAAJmZMzMAAGZmMzMA         ADMzMzMAAAAAAAD/////AAD//8zMAAD//5mZAAD//2ZmAAD//zMzAAD//wAAAADMzP//         AADMzMzMAADMzJmZAADMzGZmAADMzDMzAADMzAAAAACZmf//AACZmczMAACZmZmZAACZ         mWZmAACZmTMzAACZmQAAAABmZv//AABmZszMAABmZpmZAABmZmZmAABmZjMzAABmZgAA         AAAzM///AAAzM8zMAAAzM5mZAAAzM2ZmAAAzMzMzAAAzMwAAAAAAAP//AAAAAMzMAAAA         AJmZAAAAAGZmAAAAADMz7u4AAAAA3d0AAAAAu7sAAAAAqqoAAAAAiIgAAAAAd3cAAAAA         VVUAAAAAREQAAAAAIiIAAAAAEREAAAAAAADu7gAAAADd3QAAAAC7uwAAAACqqgAAAACI         iAAAAAB3dwAAAABVVQAAAABERAAAAAAiIgAAAAAREQAAAAAAAO7uAAAAAN3dAAAAALu7         AAAAAKqqAAAAAIiIAAAAAHd3AAAAAFVVAAAAAEREAAAAACIiAAAAABER7u7u7u7u3d3d         3d3du7u7u7u7qqqqqqqqiIiIiIiId3d3d3d3VVVVVVVVREREREREIiIiIiIiERERERER         AAAAAAAA         </data> ...         <key>general</key>         <data>         AAADcAAVABIBAAAAAAAAAAADAAkAAAAAAAAAAAADAAkAAAAAAAAAAD/pmZmZmZmaP+mZ         mZmZmZo/6ZmZmZmZmj/pmZmZmZmaAQAAAAAMAAAAAAAAAAABAAAAAQEBAAEBAQAAAQBk         AAEAAgACAAEAAQABAAEBAQEAAQAAAAABAAAFAAAAA7UAAAAAAAEAAAABUlNFRAEAAAAA         MgABAAAAAAABAAEBAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAoAAAAHgAAAABAAA         AAgAAABIAAAAAQAABAAAAAAAAAEAAAABAAAAAAKAAAAB4AAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFABGAF8AQEA         AAABAQAAAQAOAQEAAAABAAAAAAAAAAAADwEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA         AAAAAAAAAAAAAAAAAAABAAABAQAAAAEAAAA/8AAAAAAAAAAAP+zMzMzMzM0/6ZmZmZmZ         mj/pmZmZmZmaP+mZmZmZmZoBLAAAAIAAAwADAABqcGVnAAAAAAAAAAADAHJwemEAAAAA         AAAAAAMAAAADAAAMAAAAAAAYAAfQAAAAAAAAAAMAAAADAAAAAAABAAAAP9AAAAAAAAAA         AAAAAAA/1mZmZmZmZgAAAAAAAD/gAAAAAAAAAAAAAAAAP+ZmZmZmZmYAAAAAAAA/8AAA         AAAAAAAAAAAAAD/zMzMzMzMzAAAAAAAAP/MzMzMzMzMAAAAAAAA/8zMzMzMzMwAAAAAA         AD/QAAAAAAAAQFmAAAAAAAAAAz/wAAAAAAAAAAAAAAAAAAAAAAAAJagAABvQAQEAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAyAAAAAAAAAABAAEA         AAADAAAAAABkAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAAAA         AUAAAADwAAAABQAAAAAAAAAA////////AAAACQAAAAAAAAAAAAAAAAAAAAEAAAABAAAA         AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAP///////wAAAAD//wAA         //9ERAAAAAD///////93d3d3d3d3d3d3//93d///d3d3d////////3d3d3f//3d3////         ////AAD///////8AAAABAAAAAQAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAAAAAAB         AAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWgAAAAAAAAACAAAA         AAAAAAAAAAKAAAAB4AAAAAUAAAABAAAAQAAAADQAAAADAAAACQAAAAAAAP///////wAA         AAAAAAAAAAAAAAAAAUAAAADIAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAUA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAABAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AwAAAAEAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAA         AAEAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB         AAAAAAAAAAcAAAABAAAAlgAAACAAAAAAAAAAAAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAA         AQAAAAEBcgAAAAAAAAFnAAAAAAAAAWIAAAAAAAADcGFsAAAAAAAAAAAAAAAAAAAAAAAD         AAAAAAAAAAMAAAAMAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAA         AAAAgAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAABAAAA         AQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAoAAAAKAAAAAAAAAAoAAAAFAAAAAQAA         AAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAABAAAABQAFAAAAAQAAAAAAAAAAAAAAZAAAAGQAAAABAAAAAwAAAAEAAAAAAAAAAQAA         AAAAAAABAAAABQAAAAMAAAAAAAAAAAAAzM0AAAABAAAAAQAAAAAAAAAAAAAAAEdLT04A         AAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEqKioqKioqKgAAAAAA         AAAAAAAAAAAABAAAAAAFAAAABQAAAAAAAAAAAAABLAAAAMgAAAAAAAACCAAAAZQAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAFIqY2gAAAADAAACAAAAAgAAAAAAAAAA         AAAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAA         AAEAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAEA         AAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAB         AAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAEAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAEAAAAyAAAAMgAAAAAAAAAAAAEAAAAA         AAAAAQAAAAEAAAAAAAAAFAAAAAAAAAABAAAAAAAAAAEAAAABAAAAAQAAAABNT1NTAAAA         AQAAAB4AAAABAAAAAQAAAAAAAAAAAQYAAQAAABQAAAAUAAAAAAAAAAAAAAABAAAAAAAA         AAQAAAADAAAAAAAAAAEAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAyAA         AAMgAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGQAAAAAAAAAAAAAAAEAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAEAAAABAAAAAAAAAAAAAAD6AAAAAAAAAAAAAAAAAAAAAAABACwAAwHqBAYAAAC0AAAA         AAAAAAAAAAAyAAAAAUAEAAAAAAAAQAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAbgAA         AG4AAAABAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAA         AAAAAAAAAAAAAAH///////8AAAAAAAAAAAAAAAgAAAABAAAAAgAAAAEAAAABAAAAMv//         /////wAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAA         AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAA         AAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlgAAAAEA         AAABAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAACWAAAADIAAAAAAAAAAAAAAAEAAAe9AAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAA         AAEAAAAeAAAAAQAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAMAAAAAQAAABQAAAAUAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAA+gAAAAAAAAACwAAAFAAAAAAAAAAAAAAAAAAAAAB         AAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADw8PDw8PAP         Dw8PDw8AAACWAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAA         AAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAeAAAAAQAAAAAAAAABAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAB         AAAAAQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAT/wAAAAAAAAAAAA         AAAAAAAAAAABAAAAAAADDUAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQAA         mZoAAQAAAAEAAAABAAAAAAAKAAAAAAAAAAMAAAABAAAAAQAAAAQAAAAAAAAAAAAAAAAA         AAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAQAAABkAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAA         AAAAAAEAAAABQCgAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAEAAAAAAAA         ABQAAAABAAABQAAAAPAAAABIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAGAAAAXwAA         AAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAEA         AAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAA         AAEAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAEA         AAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAR0tPTgAAAAEAAAAB         AAAAAQAAAAFqampqamoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEA         AAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAAAAAAAABLAAAAAAAAAABAAAAAAAAAAAAAAAB         AAAABAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAeAAAAAAAAB9QAAAACAAAA         GAAAAAwAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAA         AAEAAAAAAAAAAAAAAAEAAIAAAAAAAQAAAAAAAABAAAAAAAAAAAAAAAAA//8AAAAAAAAA         AQAAAAEAAACFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAUgAAAAAAAEBSAAAAAAAA         AAAAAQAAAAEAAAAAAAAAAHd3d3d3dwAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAA         AAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAB         AAAAAQAAAAAAAAAAAAAAAAAAADwAAAACAAAAAAAAAAAAAAMgAAACWAAAAAEAAAAAAAAA         AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAb4oQgwA         AAAAAAAAAQAAAAAAAAAEAAAAAwAAAAEAAAACAAAAAwAAAAQAAAACAAAAAQAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAIAAAAyAAAA         AQAAAAEAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAAAAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAABAAAAAAAAAAAA         AAAAAAAAAAAAAAAAAABkAAAACQAAAAH///////8AAAABAAAAAQAAAAQ/Pz8/AAAAAAAA         AAAAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAMAAAAOAAAAAAAAAAAAAAAASlBFRz8/Pz8A         AAADAAAAAA==         </data> ...         <key>serial 2</key>         <string></string>         <key>string 0</key>         <string></string>         <key>string 1</key> ...         <key>string 23</key>         <string></string>         <key>string 24</key>         <string>Movie</string>         <key>string 25</key>         <string>YYYY-MM-DD HH.NN.SS</string>         <key>string 26</key>         <string>THM TXT HTM HTML EXE DLL P C PAS CC ASM COM SYS LST DOC XLS PST OST INI PPT INF SIT ZIP TAR MIM GZIP ARJ</string>         <key>string 27</key>         <string>THM TXT HTM HTML EXE DLL P C PAS CC ASM COM SYS LST DOC XLS PST OST INI PPT INF SIT ZIP TAR MIM GZIP ARJ</string>         <key>string 28</key>         <string></string>         <key>string 29</key>         <string>n-cc-rr.x</string>         <key>string 3</key>         <string>en</string>         <key>string 30</key>         <string>target="_blank"</string>         <key>string 31</key>         <string>ftp://</string>         <key>string 32</key>         <string></string>         <key>string 33</key>         <string></string>         <key>string 34</key>         <string>/</string>         <key>string 35</key>         <string>grab</string> ... </dict> </plist> 

As we mentioned, some application preferences are hidden. However, if you are interested, you can spend some time discovering possible preferences. Using the strings command can assist in discovering hidden preferences. You see a list of all textual strings in the program. It's reasonable to expect that for the program to read strings out of a .plist file, it must contain the string, so the strings found in the program make for potentially interesting things to try as preferences. For example, to try to discover some of the available hidden preferences in the Dock, you might run

 strings /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock | more 

Some of the output you get includes the following excerpts:

 __dyld_mod_term_funcs __dyld_make_delayed_module_initializer_calls __dyld_image_count __dyld_get_image_name __dyld_get_image_header __dyld_NSLookupSymbolInImage __dyld_NSAddressOfSymbol libobjc __objcInit The kernel support for the dynamic linker is not present to run this program. showhidden showshadow DoesPointToFocusCursorUpdate ClientMayIgnoreEvents com.apple.finder DockProxyPSNLoHack en_US Info.plist trashlabel owensdock dock .dock AppleShowAllExtensions AppleShowAllFiles notfound trashfull trashempty finder openfolder wvousfloat wvousfloatselected wvouscornertl wvouscornertr wvouscornerbl wvouscornerbr shadow /System/Library/CoreServices/Finder.app SetsCursorInBackground .app autohide magnification /System/Library/PreferencePanes/Dock.prefPane poof.png ... TrashName TrashRemoveFromDock Trash Remove From Dock default.plist com.apple.dock version persistent-apps ... orientation bottom left right pinning middle start mineffect genie scale suck ... size-immutable magnify-immutable autohide-immutable position-immutable mineffect-immutable contents-immutable ... 

As you can see, the resulting output contains a variety of items, from comments to filenames to possible preference names and possible preference values. From the output, we might guess that orientation is a preference and that possible values are bottom, left, or right. We might also guess that mineffect is another preference with possible values of genie, scale, or suck. From the Dock control pane, however, we have only the choices of genie or scale, so we've probably already discovered a sort of hidden preference. In that same section of output is pinning, which looks as if it might have possible values of middle or start. In the final section of the shown output, a number of entries that end in immutable, making it seem as if there might be a way to set some preferences so that they don't change. Without experimenting, though, we can't be sure what behavior, if any, to expect. In the middle, there's an entry for poof.png, which is an image file wonder if that's the Dock "poof" for when you remove things from it by dragging, and whether we could customize that little animation by finding and editing this graphics file?

Instead of requiring you to edit XML files directly, Apple has provided a convenient command-line program for editing the preferences stored in these files. The defaults command allows you to specify a preference to be modified and a value with which to modify it. If the application whose preferences you are trying to modify is currently running, restart the application. As an example of the defaults command in use, the following command pins the Dock at the beginning side of the Dock, as shown in Figure 16.1:

 defaults write com.apple.dock pinning start 

Figure 16.1. Here is an example of the Dock with the pinning preference set to start.


Specifically, this command modifies the preference pinning in the file ~/Library/Preferences/com.apple.dock.plist and sets the value to start. Logging out and logging back in is one way to cause changes to the Dock to take effect. More easily, you can run killall Dock. Now this file contains these lines:

 <key>pinning</key> <string>start</string> 

If you decide you don't like the pinning that you've just enable, you can always remove it. To remove the change run:

 defaults delete com.apple.dock pinning killall Dock  

Suppose that you don't want to have available the option to hide the Dock. You might try enabling the autohide-immutable item we saw earlier in the output by using the following command:

 defaults write com.apple.dock autohide-immutable -bool true 

The command modifies the preference autohide-immutable to have the Boolean value true by adding these lines to the file:

 <key>autohide-immutable</key> <true/> 

In the Dock control pane, the option to hide the Dock is no longer available, and the option no longer appears under the Apple menu. Figure 16.2 shows the modified Dock control pane.

Figure 16.2. After setting the autohide-immutable preference to true, the option to hide the Dock is no longer available.


As you have seen, preferences files can vary in their complexity. You might sometimes find it easier to edit the actual plist file or use the graphical /Developer/Applications/Utilities/Property List Editor.app. For example, from the earlier strings output on the Dock preferences, we notice the persistent-apps string. This suggests that there might be a way to remove icons that permanently appear in the Dock. However, just from the persistent-apps string, it is difficult to guess what you might have to do to remove one of those icons. Because that section in the ~/Library/Preferences/com.apple.dock.plist file also looks complicated, it might be difficult to guess what the appropriate defaults command may be. However, in your favorite text editor, or in the Property List Editor, you can easily locate the section for the application you no longer want to have in your Dock and simply delete it. Figure 16.3 shows removing the AddressBook section of the persistent-apps section of the file using the Property List Editor. You can tell that item 4 of the persistent-apps section, the item to be removed, is the Address Book based on the file-label value.

Figure 16.3. Using the Property List Editor to remove the Address Book icon from the Dock.


Unfortunately, Apple hasn't provided a definitive list of preferences options for each application. Even a listing of the options that each file contains would not be complete because some applications accept preferences that are not yet stored in the XML files. There are preferences options that some programs take as defaults but that can be overridden by the insertion of specific preferences into the XML files. Because no current preference is stored, we can only make intelligent guesses as to what preference names and values might be accepted. As a matter of fact, making intelligent guesses is exactly what the online community is doing regarding these preferences. With this brief look at discovering and manipulating some preferences in the Dock, you can also start to make some intelligent guesses regarding preferences.

Table 16.1 lists a number of preferences options that have been reported to be interesting, when configured using the defaults command. Not all these have known or well- documented functions. We have primarily tested those for the Finder and the Dock. In our testing of the NSUserKeyEquivalents preference, we had success in building key equivalents with the Command and/or Shift characters. However, we list all the reported information on <keystring> values, in case it should indeed prove useful. Figure 16.5 shows Terminal.app's Terminal menu modified so that About Terminal, which normally does not have a keyboard equivalent, now has a keyboard equivalency of Shift-Command-b. You can set this particular equivalency by running this defaults command:

 defaults write com.apple.Terminal NSUserKeyEquivalents '{"About Terminal"="$@b";}' 

Table 16.1. A Number of the Interesting defaults Preferences Options That Have Been Reported as Having Interesting Effects on the Interface

Issue command as

defaults write <domain> <key> <value>

<domain>

<key>

<value>

Effect

com.apple.finder

Finder.HasDarkBackground

-bool true

-bool false

Some text appears as white with a black outline or as solid black.

 

ShowHardDrivesOnDesktop

-bool true

-bool false

Does or does not show hard drives on the desktop.

 

ShowRemovableMediaOnDesktop

-bool true

-bool false

Does or does not show removable media on the desktop.

 

ProhibitEmptyTrash

-bool true

-bool false

Does or does not remove the option to empty the trash.

 

ProhibitFinderPreferences

-bool true

-bool false

Does or does not remove the Finder preferences option.

 

ProhibitEject

-bool true

-bool false

Does or does not remove the option to eject removable media.

 

ProhibitBurn

-bool true

-bool false

Does or does not remove the option to burn recordable media.

 

ProhibitGoToiDisk

-bool true

-bool false

Does or does not remove the option to go to the iDisk.

 

ProhibitGoToFolder

-bool true

-bool false

Does or does not remove the option to go to a folder.

 

ProhibitConnectTo

-bool true

-bool false

Does or does not remove the option to connect to a server.

 

AppleShowAllFiles

-bool true

-bool false

Does or does not show all files. Normally false, which hides some files.

 

AnimateWindowZoom

-bool true

-bool false

"Zoom" windows open from their icon locations, or make them simply appear in place.

com.apple.

loginwindow

Finder

<path>

Launches the application specified by <path> at login instead of the Finder.

com.apple.dock

showhidden

-bool true

-bool false

Does or does not dim Dock icons for hidden applications.

 

showshadow

-bool true

-bool false

Does or does not display a slight drop shadow along the edge of the Dock.

 

mineffect

genie

suck

scale

Known values for different Dock minimization effects.

 

orientation

left

bottom

right

Known values for Dock position.

 

pinning

start

middle

end

Known values for anchoring the Dock in its position.

 

autohide-immutable

-bool true

-bool false

Does or does not make available the option to automatically hide and show the Dock.

NSGlobalDomain

NSInterfaceStyle

nextstepdefaults

macintoshdefaults

windowdefaults

Turns off antialiasing below <size> can be set higher than the prefs menu allows (16 is sufficient for finder menus).

 

NSFixedPitchFontSize

<fontsize>

 

NSFontSize

<fontsize>

 

NSSystemFontSize

<fontsize>

 

AppleAntiAliasingThreshold

<size>

<any application domain>

NSUserKeyEquivalents

'{"<menuitem>"=

"<keystring>";}'

<menuitem> is any named menu item in a Cocoa application.

<keystring> is built from:

@ = Command

$ = Shift

~ = Option

^ = Control

and any other character.

Modifies the key equivalent for a menu item.


NOTE

This table includes information from our own investigation as well as excerpts from information collected on the Internet from a variety of places, including

http://www.macosxhints.com/search.php?query=defaults+write&mode=search&datestart=0&dateend=0&topic=0&type=stories&autho=0

http://www.macnn.com/

http://www.pixits.com/defaults.htm


Figure 16.4. About Terminal under the Terminal menu of Terminal.app now has a keyboard equivalency of Shift-Command-b after issuing the appropriate defaults command.


Table 16.2 shows select documentation for the defaults command. Note that not only can you use the defaults command to write preferences, but you can also use it to read, delete, and search preferences.

Table 16.2. Select Documentation Table for the defaults Command

defaults

Accesses the Mac OS X user defaults system.

defaults [currentHost | -host <hostname>] read [<domain> [<key>]]

defaults [currentHost | -host <hostname>] read-type <domain> <key>

defaults [currentHost | -host <hostname>] write <domain> {'<plist>' | <domain> <key> [']<value>[']}

default [currentHost | -host <hostname>] rename <domain> <old-key> <new_key>

defaults [currentHost | -host <hostname>] delete [<domain> [<key>]]

defaults [currentHost | -host <hostname>] { domains | find <word> | help } defaults allows users to read, write, and delete Mac OS X user defaults from the command line.

Applications use the defaults system to record user preferences and other information that must be maintained when applications aren't running, such as the default font for new documents. Because applications do access the defaults system while they are running, you should not modify the defaults of a running application.

User defaults belong to domains, which typically correspond to individual applications. Each domain has a dictionary of keys and values to represent its defaults. Keys are always strings, but values can be complex data structures made up of arrays, dictionaries, strings, and binary data. These data structures are stored as XML property lists.

Although all applications, system services, and other programs have their own domains, they also share a domain called NSGlobalDomain. If a default is not specified in the application's domain, it uses the default listed in the NSGlobalDomain instead.

<domain> is specified as follows:

<domain_name> | -app <application_name> | -globalDomain

Subcommands

read

Prints all the user's defaults for every domain to standard output.

read <domain>

Prints all the user's defaults for the specified <domain> to standard output.

read <domain> <key>

Prints the value for the default of the <domain> identified by <key>.

write <domain >

Writes <value> as the value for <key> in <domain>.

<key> '<value>'

<value> must be a property list, and must be enclosed in single quotes. For example:

defaults write com.companyname.appname "Default Color" '(255, 0, 0)'

sets the default color in com.companyname.appname to the array containing 255, 0, 0 (red, green, blue components). Note that the key is in quotes because of the space in its name.

write <domain>

Overwrites the defaults information in '<plist>' <domain> with that specified in <plist>. <domain> must be a property list representation of a dictionary, and must be enclosed in single quotes. For example,

 defaults write com.companyname.appname '{ "Default  Color" = (255, 0, 0); "Default Font" = Helvetica; }' 

Overwrites any previous defaults for com.companyname.appname and replaces them with the ones specified.

delete <domain>

Deletes all default information for <domain>.

delete <domain> <key>

Deletes the default named <key> in <domain name>.

domains

Prints the names of all domains in the user's defaults system.

find <word>

Searches for <word> in the domain names, keys, and values of the user's defaults, and prints out a list of matches.

help

Prints a list of possible command formats.

Options:

-g

When specifying a domain, -g can be used as a synonym for NSGlobalDomain.

Specifying <value> for Preference Keys

<value>

Specifies <value> as a string value to use.

'<value>'

Specifies <value> as a string value to use.

-string <string_value>

Specifies <string_value> as the string to use.

-data <hex_digits>

Specifies <hex_digits> as the data to use.

-int[eger] <integer_value>

Specifies <integer_value> as the integer value to use.

-bool[ean] true | false |

yes | no

Specifies the Boolean value to use.


     < Day Day Up > 


    Mac OS X Tiger Unleashed
    Mac OS X Tiger Unleashed
    ISBN: 0672327465
    EAN: 2147483647
    Year: 2005
    Pages: 251

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