- 3.3. Customizing Spotlight
You've just read about how Spotlight works fresh out of the box. But you can tailor its
behavior, both for security reasons and to fit it to the kinds of work you do.
Here are three ways to open the Spotlight preferences center:
• Choose Spotlight Preferences at the bottom of the Spotlight menu just after you've
performed a search.
• Use Spotlight itself.Hit -Space bar, type spotl, and press Enter.
• Choose System Preferences. Click Spotlight.
In any case, you wind up face-to-face with the dialog box shown in Figure 3-6.
Figure 3-6. Here's where you can specify what categories of icons you want Spotlight
to search, which order you want them listed in the Spotlight menu, and what
keystroke you want to use for highlighting the Spotlight bar.
You can tweak Spotlight in three ways here, all very useful:
• Turn off categories. The list of checkboxes identifies all the kinds of things that
Spotlight tracks. If you find that Spotlight uses up valuable menu space listing,
say, Web bookmarks or fonts—stuff you don't need to find very often—turn off
their checkboxes. Now the Spotlight menu's precious 20 slots are allotted to icon
types you care more about.
• Prioritize the categories. This dialog box also lets you change the order of the
category results; just drag an individual list item up or down to change where it
appears in the Spotlight menu.
The factory setting is for Applications to appear first in the menu. That makes a lot
of sense if you use Spotlight as a quick program launcher (which is a great idea).
But if you're a party planner, and you spend all day on the phone, and the most
important Spotlight function for you is its ability to look up someone in your
address book, then drag Contacts to the top of the list. You'll have fewer arrow-
key presses to perform once the results menu appears.
- POWER USERS' CLINIC
The Raw Power of the Raw Query
You may have just slogged through over 20 pages of Spotlight details—but if
you can believe it, there are another 40 or 60 to be written. It turns out that the
Spotlight most people see is only a subset of the true power awaiting in
For example, what if you wanted to see all the files you've opened in the last 24
hours except email messages and address book entries? Or what if you want to
round up all PDF documents and PostScript files you've opened in the last
week? Using the Spotlight tools that most people see, you wouldn't be able to
set up searches or smart folders that are quite that smart.
Fortunately for the true Leopard geek, Spotlight also understands a query
language—a programming-like syntax that lets you establish far more specific
and nuanced searches. You can use it to pull off stunts that would be impossible
using the Spotlight menu or window alone.
To read about the basics of the query language, start at
http://developer.apple.com/macosx/spotlight.html; it will lead you to a number
of Web pages that explain the full scope of Spotlight's internal lingo.
You may also get a kick out of studying how Spotlight uses the query language
itself. To do that, create a smart folder, and then Get Info on it. (Control-click or
right-click it and, from the shortcut menu, choose Get Info.) On the General
panel, inspect the string of query text that Spotlight generated behind the scenes
(as shown here).
What you'll learn is that the basic search command always includes the
command kMDItem. To search for something by its file type, your query should
begin with kMDItemContent-Type; for when you last opened it, use
kMDItemLastUsed-Date; and so on.
For example, here's how you'd type a query that rounds up all files that contain
the keyword "kumquat": kMDItem-Keywords == "*kumquat*". (The double =
symbol means "equal." You can also use ,
- Once you've read more about this query language, you can build much more
complicated searches. This one, for example, finds all audio files, whose author
is either Kevin or Steve, that were modified in the last week:
((kMDItemAuthors == "Kevin"wc ||
kMDItemAuthors == "Steve"wc) &&
(kMDItemContentType == "audio"wc ||
kMDItemContentType == "video"wc))
&& (kMDItemFSContentChangeDate == $time.this_week)
And here's how you'd find all PDF documents and PostScript files with a single
((kMDItemContentTypeTree == 'com.adobe.pdf') ||
(kMDItemKind == 'Post-Script document'))
(Most of this stuff actually stands for useful things: MD for metadata, wc for
"word-based, case-insensitive," and so on.)
And where, you may ask, are you supposed to type all these queries? You have
In the Finder, when you choose File Find to produce the Spotlight window,
choose Other from the Kind pop-up menu. In the list of six gazillion search
parameters, choose Raw Query. You can type your elaborate search string into
the text box that appears.
Second, you can open Terminal (Chapter 16) and use Spotlight's Unix
equivalent. The main command you want to learn about is mdfind. For example,
at the Terminal prompt, you could type mdfind "kMDItemAcquisitionModel ==
'Canon PowerShot S80'" (and then press Enter) to see a list of all photos you
took with that particular camera model.
Spotlight: The Missing Manual? Hmm. Has a nice ring to it, doesn't it?
- • Change the keystroke. Ordinarily, pressing -Space bar highlights the Spotlight
search box in your menu bar, and Option- -Space bar opens the Spotlight
window described above. If these keystrokes clash with some other key
assignment in your software, though, you can reassign them to almost any other
keystroke you like.
Most people notice only the pop-up menu that lets you select one of your F-keys
(the function keys at the top of your keyboard). But you can also click inside the
white box that lists the keystroke and then press any key combination—Control-S,
for example—to choose something different. Whatever keystroke you choose must
include at least one of the modifier keys (Option, Control, or ) or one of the F-
keys (such as F4).
Note: Apple assumes no responsibility for your choosing a keystroke that messes up
some other function on your Mac. -S, for example, would not be a good choice.On
the other hand, if you choose a Spotlight keystroke that Mac OS X uses for some other
function (like Shift- -3), a little yellow alert icon appears in the Spotlight pane. This
icon is actually a button; clicking it brings you to the Keyboard & Mouse pane, where
you see exactly which keystroke is in dispute, and change it.
Figure 3-7. You can add disks, partitions, or folders to the list of non-searchable
items just by dragging them from the desktop into this window. Or, if the private
items aren't visible at the moment, you can click the + button, navigate your hard
drive, select the item, and click Choose. To remove something from this list, click it
and then press the Delete key or click the – button.
3.3.1. Privacy Settings
Ordinarily, Spotlight doesn't consider any corner of your hard drive off-limits. It looks for
matches wherever it can except in other people's Home folders. (That is, you can't search
through other people's stuff).
- But even within your own Mac world, you can hide certain folders from Spotlight
searches. Maybe you have privacy concerns—for example, you don't want your spouse
Spotlighting your stuff while you're away from your desk. Maybe you just want to create
more focused Spotlight searches, removing a lot of old, extraneous junk from its
Either way, the steps are simple. Open the Spotlight panel of System Preferences, as
described above. Click the Privacy tab. Figure 3-7 explains the remaining steps.
Tip: When you mark a disk or folder as non-searchable, Spotlight actually deletes its
entire index (its invisible card-catalog filing system) from that disk. If Spotlight ever
seems to be acting wackily, you can use this function to make it rebuild its own index file
on the problem disk. Just drag the disk into the Privacy list and then remove it again!
Spotlight deletes, and then rebuilds, the index for that disk.(Don't forget the part about
"remove it again," though. If you add a disk to the Privacy list, Spotlight is no longer able
to find anything on it, even if you can see it right in front of you.)
Once you've built up the list of private disks and folders, close System Preferences.
Spotlight now pretends the private items don't even exist.
nguon tai.lieu . vn