# 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:

local myWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", hs.reload):start()

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

  • new

Methods - API calls which can only be made on an object returned by a constructor

  • start
  • stop

# API Documentation

# Constructors

# new

| | | | --------------------------------------------|-------------------------------------------------------------------------------------| | 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 changed flagTables: a table containing a list of tables denoting how each corresponding file in paths 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+)
| | Returns |
  • An hs.pathwatcher object
| | Notes | | | Examples | None | | Source | extensions/pathwatcher/libpathwatcher.m line 83 |


# Methods

# start

Signature hs.pathwatcher:start()
Type Method
Description Starts a path watcher
Parameters
  • None
Returns
  • The hs.pathwatcher object
Notes None
Examples None
Source extensions/pathwatcher/libpathwatcher.m line 153

# stop

Signature hs.pathwatcher:stop()
Type Method
Description Stops a path watcher
Parameters
  • None
Returns
  • None
Notes None
Examples None
Source extensions/pathwatcher/libpathwatcher.m line 175