#hs.pathwatcher
Watch paths recursively for changes
This simple example watches your Hammerspoon directory for changes, and when it sees a change, reloads your configs:
This module is based primarily on code from the previous incarnation of Mjolnir by Steven Degutis.
#API Overview
Constructors - API calls which return an object, typically one that offers API methods
Methods - API calls which can only be made on an object returned by a constructor
#API Documentation
#Constructors
| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | Signature | hs.pathwatcher.new(path, fn) -> watcher
| | Type | Constructor | | Description | Creates a new path watcher object | | Parameters |
- path - A string containing the path to be watched
- fn - A function to be called when changes are detected. It should accept two arguments:
paths
: a table containing a list of file paths that have changedflagTables
: a table containing a list of tables denoting how each corresponding file inpaths
has changed, each containing boolean values indicating which types of events occurred; The possible keys are:mustScanSubDirsuserDroppedkernelDroppedeventIdsWrappedhistoryDonerootChangedmountunmountitemCreateditemRemoveditemInodeMetaModitemRenameditemModifieditemFinderInfoModitemChangeOwneritemXattrModitemIsFileitemIsDiritemIsSymlinkownEvent (OS X 10.9+)itemIsHardlink (OS X 10.10+)itemIsLastHardlink (OS X 10.10+)
- An
hs.pathwatcher
object
- For more information about the event flags, see the official documentation