#
hs.spotlight
This module allows Hammerspoon to preform Spotlight metadata queries.
This module will only be able to perform queries on volumes and folders which are not blocked by the Privacy settings in the System Preferences Spotlight panel.
A Spotlight query consists of two phases: an initial gathering phase where information currently in the Spotlight database is collected and returned, and a live-update phase which occurs after the gathering phase and consists of changes made to the Spotlight database, such as new entries being added, information in existing entries changing, or entities being removed.
The syntax for Spotlight Queries is beyond the scope of this module's documentation. It is a subset of the syntax supported by the Objective-C NSPredicate class. Some references for this syntax can be found at:
- https://developer.apple.com/library/content/documentation/Carbon/Conceptual/SpotlightQuery/Concepts/QueryFormat.html
- https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html
Depending upon the callback messages enabled with the
You can also check to see if the initial gathering phase is in progress with the
You can access the individual results of the query with the spotlightObject[n]
will access the n'th spotlightItemObject in the current results.
#
Submodules
#
API Overview
Constants - Useful values which cannot be changed
commonAttributeKeys definedSearchScopes
Constructors - API calls which return an object, typically one that offers API methods
new newWithin
Methods - API calls which can only be made on an object returned by a constructor
callbackMessages count groupedResults groupingAttributes isGathering isRunning queryString resultAtIndex searchScopes setCallback sortDescriptors start stop updateInterval valueListAttributes valueLists