hammerspoon2-docs
    Preparing search index...

    Class HSPathWatcher

    Watches a filesystem path for changes and invokes a callback when they occur. Created via hs.fs.createPathWatcher(path). Set a callback with setCallback(), then call start() to begin receiving events.

    Flag Meaning
    "itemCreated" Item was created
    "itemRemoved" Item was removed
    "itemRenamed" Item was renamed or moved
    "itemModified" File data was modified
    "itemInodeMetaMod" Inode metadata changed (permissions, timestamps, etc.)
    "itemFinderInfoMod" Finder info changed
    "itemChangeOwner" Ownership or group changed
    "itemXattrMod" Extended attributes changed
    "itemIsFile" The item is a file
    "itemIsDir" The item is a directory
    "itemIsSymlink" The item is a symbolic link
    "itemIsHardlink" The item is a hard link
    "itemIsLastHardlink" This is the last hard link to the inode
    "itemCloned" Item was cloned
    "ownEvent" Event was generated by this process
    "mustScanSubDirs" Subtree must be rescanned (events may have been dropped)
    "userDropped" Events were dropped at the user-space level
    "kernelDropped" Events were dropped at the kernel level
    "rootChanged" The watched root path itself changed
    "mount" A volume was mounted under the watched path
    "unmount" A volume was unmounted from under the watched path
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    identifier: string

    The unique identifier assigned to this watcher.

    Methods

    • Stops the watcher and releases all resources. Called automatically during shutdown.

      Returns void

    • Sets the callback invoked when filesystem changes are detected.

      Parameters

      • fn: (paths: string[], flags: string[][]) => void

        Called with an array of changed paths and a parallel array of per-path flag string arrays.

      Returns HSPathWatcher

      self, for chaining