The hard way to find hidden Finder preferences

Sep 11, '09 07:30:05AM

Contributed by: arcticmac

This recent hint points out that the old strings approach to inspecting applications doesn't work for finding hidden preferences in Snow Leopard. I've worked out a way that works for the Finder, but it may not work with other applications (eg. I didn't have much luck with the Dock). In order to use this hint, you'll need to have the Xcode developer tools installed.

First, quit Finder. This can be done via AppleScript, or by enabling the Quit menu item in the Finder. After that, open a Terminal window (make sure it's in your Dock or running before you quit Finder). Then type:

$ cd ~/Desktop
$ gdb /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
This loads gdb (the GNU debugger) and gets it ready to debug the Finder. You can actually attach gdb to a running copy of the Finder, but (a) you need to be root, and (b) you'll miss all the lovely prefs the Finder asks for when it starts up, so you may as well start fresh.

In gdb, type (or copy and paste) the following:

set logging on
break CFPreferencesCopyAppValue
commands 1
silent
print-object [$rdi stringByAppendingFormat:@";%@",$rsi]
continue
end
run
This basically tells gdb to log the preference string and preference domain every time Finder looks up a preference.

After you hit Return after typing run, gdb will start Finder, and you'll start seeing messages flash by. I recommend you hide Terminal, then switch to Finder and use it normally for a while in order to log a bunch of preference requests. When you're satisfied, quit Finder again (see, aren't you glad you enabled the Quit menu item like I suggested?), switch back to gdb in Terminal, and type quit.

Now, if you look on your Desktop (or elsewhere, if you cd'd somewhere else way back at the beginning), you'll see a file called gdb.txt. If you're a glutton for punishment, you can look through it as it is. But I suggest you open it up quick and delete the first few lines (the stuff gdb printed before it got down to the preferences stuff), and then close it and do the following in your Terminal window (you kept that same window open, right, so you won't need to cd again?):
sort -u -o FinderPrefs.txt gdb.txt
sort will alphabetize the preference keys, and remove duplicates (that's what -u does), which makes your job much much easier.

One last note about the format of the file. I picked a semicolon as the delimiter between the preference and the domain because that shouldn't show up anywhere else in the file. Once you open the file, you can search through for spaces to find any additional lines gdb output, and once you've deleted all those, you can change the semicolons to something more readable.

Oh, and if you're wondering what all the kCFPreferencesCurrentApplication domains mean, you might want to consult this page.

[robg adds: I didn't mark this one as Snow Leopard only, because gdb should also work in 10.5. I haven't tested this one.]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090831185657563