In a recent Mac OS X Hints blog, I explained how you can use Terminal to control a number of features that Apple removed from iTunes 8—including the ability to toggle the iTunes Store link arrows on and off, for instance. While relatively simple, the Terminal commands to control these “hidden” preferences aren’t documented anywhere, so I’m often asked “just how do you find these things?” The answer, as with the Wizard of Oz (“Pay no attention to that man behind the curtain”) is that things that appear magical may actually be quite simple, once you know how they’re done.
To go digging for hidden preferences in applications, there are a few prerequisites. Ideally, you’ll have another system—whether that’s a version of OS X installed on a FireWire drive or partition, or a completely separate Mac, is really up to you. This isn’t really required, but it’s definitely the safest way to experiment. Note that I’ve never permanently messed up an application by experimenting with preferences; at worst, I’ve had to trash the preferences file.
You’ll also need a text editor that supports a “find all” feature—that’s the ability to display all matches for a given search string in one window. You’ll find such a feature in the freeware editors Smultron and TextWrangler, as well as in any number of paid-for editors. You’ll also need to use Terminal, though not in any overly-complex manner. Finally, you’ll need your sense of adventure, as you head off in search of the great hidden preferences.
As you head off on this adventure, please keep in mind that it’s potentially dangerous (though only in the “testing” phase), and that you should proceed at your own risk—I’ll guide you through the process, but anything that may happen to your machine or applications is solely your responsibility.
Assuming you meet all the prerequisites, and you understand the risks involved, here’s how to go about finding and testing hidden preferences for a given program. I’m going to use iTunes 8 as my example, but the general methods apply to pretty much any OS X program, so you can easily use this technique on other programs. (The following is lengthy, but that’s mainly because I’m trying to explain each step in some detail; it’s really not as hard as it may appear.)
Get the data
The first thing to realize about hidden preferences is that in order to work, they must be coded in the program’s actual code—so we’re going to look for hidden preferences by finding all the actual text within a given program’s code, then start digging through that text looking for clues. But if you try to open the iTunes application (the actual program file, not the application bundle; see below) in TextWrangler, you’ll see nothing but gibberish, as seen in the screen at right. That’s because programs are stored as binary data, and binary data doesn’t do well when opened in a text editor.
There is, however, a Unix command named
strings that will pull all the actual text out of binary file. So the first step in hunting for hidden preferences is to dump the program’s text strings into a file. To do that, you need to find the actual program code. Open Terminal, and type
cd /Applications/iTunes.app/Contents/MacOS, then press Return. This will set the working directory to the location of the iTunes 8 binary. This same path should hold true for most any OS X program—you’ll find the binary in the MacOS folder, within the Contents folder inside the application bundle. To see what’s here, type
ls and press Return. In most cases, you’ll only see one file (named
iTunes in this case), and this file is the program’s actual binary code.
Now we’ll use
strings to find any text within the binary, and dump it to a file on the desktop. Type this command, then press Return:
strings - iTunes >~/Desktop/itunes_strings.txt
There’s only one odd bit in this command—the hyphen just after
strings is required to make sure the command searches every byte of the program for text strings; if you leave this out, you won’t get anything useful in the output file. After the hyphen, we enter the name of the program (
iTunes) we want to run
strings against. After that, the section starting with the greater-than sign tells Terminal to route the output from this command to a file named
itunes_strings.txt on the desktop.
Depending on the speed of your machine and the size of the program, it may take a few seconds before you see the command prompt return in Terminal. Once you do, that tells you the command is done and the file is ready for you to use in the next step of the process.
Dig into the data
From here, the difficulty of the task at hand depends on what you know about your elusive targets—the more you know about the hidden preferences you’re looking for, the better. At the hardest end of the scale, assume you’re looking at a brand-new program, and you’re wondering if the developer hid any preferences in the code that they didn’t include in the GUI. If that’s the case, you’ve got a herculean task in front of you: because you don’t know exactly what you’re looking for, you have to look at everything.
In your text editor of choice, open the text file you just created with the
strings command, and then (ugh) just start scrolling through it, looking for interesting-looking words and phrases. What sorts of words and phrases, exactly? Unfortunately, that question is nearly impossible to answer, because it will vary so much from program to program. Typically, though, keep an eye out for phrases-that-are-hyphenated, and InterWordCappedStrings. If you find one that looks interesting (based solely on the name), copy and paste it to a new document for further investigation.
Once you’ve worked your way through the file, run the program in question, and see if you can find preference settings that look as though they belong to any of the words you’ve jotted down. For instance, say you found the string EnableTranslucentWindow while browsing a given app’s text. If you don’t see a preference setting related to translucent windows, you may have found a hidden preference. Read the section on testing to learn how to test your possible discoveries.
This kind of digging is my least favorite, because it’s tedious and usually not overly rewarding. It is, however, the only way I know of to find hidden preferences that you really don’t know anything about. As an example, a Mac OS X Hints reader found
no-glass in the Finder’s text strings. This string turned out to be the key to releasing Leopard’s 2-D dock at the bottom of the screen, as described in this article. (Note for advanced readers: if you have a prior version of the program, you can use
diff to compare the text strings of the two versions, which eases the workload quite a bit.)
At the easiest end of the scale is the recent iTunes 8 example. In this case, there was a set of preferences that had existed in iTunes 7. In digging into the iTunes 8 text strings, we can use key words from those missing preferences to greatly ease the search. Consider my personal pet peeve, the iTunes Store arrow links. In iTunes 7, you toggled the links on and off through a preference labeled Show Links to the iTunes Store. With that knowledge, I used TextWrangler to open the iTunes text file I had created, and then opened the search dialog (Command-F) to search on a word I thought a hidden preference would have to contain.
As a first guess, I entered links in the Find box. Instead of clicking Find (which would require lots of use of Find Again to page through all the matches), I clicked Find All (other editors may label the button differently). Find All shows all matches for your search term in one window, making it much simpler to eyeball the list for interesting-looking matches. When I scrolled about halfway down the list, I found one that jumped out:
Just from reading the words,
show-store-arrow-links seemed to be what I was looking for. Even better, though, is the display in the lower-half of the window, which shows the selected match in the context of the full file. Immediately surrounding this match are a number of other very-useful looking terms, each of which corresponds to a preference that went missing in iTunes 8—it’s always nice to hit the jackpot on your first spin!
So what now? How do we know if these words mean anything, or if they’re just leftovers from the previous version and have no role in iTunes 8? We test, of course!
Test the hidden preferences
Once you’ve identifed a possible hidden preference, how do you go about finding out whether it’s really what you suspect it is? To do that, you need to set the value of the preference in the application, then run the program and see if the feature you were trying to modify has changed. Use the
defaults write command in Terminal to give a value to your hidden preference. The big trick here is figuring out exactly what kind of value you need to give the preference. Oversimplifying a bit, there are basically three types of values a preference could have:
- Boolean: This is the most-common type, as it corresponds to a “yes or no” setting. So in iTunes 7, the iTunes Store link arrows were a “yes or no” option in preferences—they were either on (yes) or off (no). So the
show-store-arrow-linksis probably expecting a boolean value.
- Numeric: The preference is expecting a number, either an integer (4) or a floating point (4.2322) type. They’re used, for instance, in the Mouse System Preferences panel to set the mouse tracking speed.
- String: The preference is expecting a literal string of text—the Finder’s Label preferences, for example, are text strings.
To set a preference, you’ll use a specific variation on this general form of the
defaults write command syntax:
defaults write domain_of_app name_of_preference value_type value
domain_of_app can be found by looking in your user’s Library -> Preferences folder, and finding the preferences file associated with the application. For iTunes, the preferences file is com.apple.iTunes.plist. To get the domain, just drop the “.plist” at the end—so iTunes has a domain of com.apple.iTunes (and yes, capitalization counts). The
name_of_preference is the string you found that you want to test,
-bool for Boolean,
-float for numeric, and
-string for strings. Finally,
value is the value you want to assign to the variable. In the case of booleans, the value must be either
Whew. That’s much harder to explain than it is to use—in practice, I’ve found that the majority of hidden preferences tend to be for boolean values, and that’s the case for all of the iTunes 8 preferences.
The final step before assigning a value is to determine what value the program is currently using for the feature in question. In the case of the iTunes Store links, they’re enabled by default—in other words, as a boolean, the iTunes Store links are TRUE. Therefore, to see if I’ve found the hidden preference that controls this feature, I need to turn them off by setting the value to FALSE. So here’s the final command I came up with:
defaults write com.apple.iTunes show-store-arrow-links -bool FALSE
After entering that, I pressed Return, launched iTunes, and clicked an item in my library. When I didn’t see a store arrow link, I knew I’d found the preference to control this feature. But what if it had failed—what if the link arrows were still there? In that case, I’d know my command wasn’t the right one, and so I should clean up the entry I just made to the iTunes preferences. Quit iTunes, and in Terminal, enter this command:
defaults delete com.apple.iTunes show-store-arrow-links
This will delete the entry I just made to iTunes’ preferences—while it really shouldn’t cause any issues, it’s always best to get rid of things you’ve tried that don’t work. I would then go back to the iTunes text file, and try to find another candidate. But since it worked, I was done with that one. I then tested most of the other words I’d found in a similar manner, finding they all worked as described in the recent blog entry.
Digging around in a program’s binary code for hidden preferences probably isn’t everyone’s cup of tea. But if you’ve ever had a favorite program remove a beloved feature, you may find that the feature is really still there, just its presence in the GUI has been removed (as with iTunes 8). If that’s the case, this technique will help you root out such hidden-but-still there capabilities.