How do I determine that mdworker
(Spotlight) has completed its first scan? I'm basically looking for the point at which the little "." in the spotlight search icon would go away and you'd be able to perform searches. (Obviously the OS has a way to determine this since it displays a dot until it's ready...) I'm not seeing anything from mdutil
and I can't find anything in the Spotlight APIs.
I'm currently forcing my own scan synchronously using mdimport
, but this introduces a long delay (from minutes to hours depending on how aggressive I'm being about where to search) and duplicates work that mdworker
is already doing.
Any solution (programmatic, scripted, documented, or undocumented) is fair game here.
I opened a DTS for this with Apple. The answer is that there is no supported way to do this as of 10.7. The "little dot" that the spotlight search icon uses is controlled with a private interface.
My goal has been to get an inventory of installed applications.
My solution currently is to gather a list of all the apps in /Applications using fts
and searching for things named ".app", and pruning as I go so I don't get sub-applications. (This would be easier to do with NSDirectoryEnumeration
, but this particular piece of code is in C++ with Core Foundation. It would be easier to do with CFURLEnumerator
, but I need to support 10.4. So fts
is fine.)
Scanning for this list is very fast. Once I know the minimum number of apps on the box, I compare that to what system_profiler
outputs. If system_profiler
tells me that there are fewer apps than I know are in /Applications, then I scan all the bundles myself. Otherwise, I use the output from system_profiler
.
This isn't ideal, but it's a decent heuristic, is "mostly" right, and prevents drastic underreporting of applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With