14

I would like to explore some new tweaks which can be done by the "defaults write" command in OS X(ML).

What can I do to find them out myself rather than hunting online for known tweaks?

3 Answers 3

23

Disclaimer: I’m the author of ~/.osx, a collection of defaults write settings. These are the techniques that I use to find settings. Let me know if there is a better/easier method I didn’t mention here!


For most non-hidden settings, this is how you can find the correct preference keys in Terminal.app:

defaults read > a
# Change the setting
defaults read > b
diff a b

For hidden settings, it gets trickier. You can use the command-line strings utility on any binary executable and see if any of the resulting text looks like a preference key. E.g.:

strings /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder

Here’s another example that will look through all .framework files in /System/Library/Frameworks/ and filter the output somewhat:

strings /System/Library/Frameworks/*.framework/Versions/Current/* /System/Library/Frameworks/*/Frameworks/*/Versions/Current/* 2> /dev/null | grep -E '^[a-zA-Z0-9_.-]{10,80}$' | sort | uniq

There’s also a tool called GDB which can be used to find hidden preferences.

4
  • 1
    Thank you very much and I can't believe that you are replying me! I knew about your nice list at github long time ago btw. Thank you very very much! Will try this now.
    – Tom S
    Jul 31, 2012 at 11:16
  • 2
    @Lri FWIW, I’ve done a clean Mountain Lion install just last week and defaults read; works fine here. Jul 31, 2012 at 18:34
  • To check the specific type of the fields, use defaults export to check the list! Use the type -float for defaults for the type <real> in the plist
    – RexYuan
    Oct 25, 2022 at 17:39
  • Adding to this: According to this answer, you can make defaults write take effect without logout-login/restarting with activateSettings -u
    – RexYuan
    Oct 30, 2022 at 8:07
0

Another strings command:

for f in $(mdfind kMDItemContentType==public.unix-executable -onlyin /System/Library/); do strings $f 2> /dev/null | grep -E '^[[:alnum:]_.-]{10,80}$' | grep ^Apple | sort -u | sed "s/^/${f##*/} /g"; done

sudo opensnoop -n cfprefsd shows what property lists are modified. You can use fseventer to display other file system changes in real time.

defaults has a find subcommand:

$ defaults find nsquitalw
Found 1 keys in domain 'Apple Global Domain': {
    NSQuitAlwaysKeepsWindows = 1;
}

Header files often contain definitions for preference keys:

grep PreferenceKey -r ~/Code/Source/WebKit/ | grep '\.h:'
-1

What i assumed from your question is you want to explore tweaks/settings of an application. You can read preferences of an app with this trivial command

defaults read NSGlobalDomain

or

defaults read com.google.Chrome to read chrome writeable preferences from defaults write command which you asked for.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .