ProcessWatcher v0.8.4

A Hammerspoon Spoon that watches for processes that have gotten out of hand (sustained high CPU or memory usage), warns via an actionable macOS notification, and shows current status in the menu bar.

Overview

Variables

ProcessWatcher.configPath Variable #

Path to the JSON config file (default: ~/.config/ProcessWatcher/config.json).

Methods

ProcessWatcher:loadConfig() Method #

Loads config from configPath, merged with any values previously passed to configure(), filling in defaults for missing keys. Never writes configPath -- it is purely hand-managed. Errors (via error()) if the resulting config is invalid (e.g. interval >= sustainSeconds) without touching any previously-loaded config -- so a broken on-disk file can never disrupt already-running monitoring via reloadConfig(), only prevent a first-ever start().

ProcessWatcher:configure(cfg) Method #

Merges cfg into the Lua-side config overlay and recomputes the effective config against the current on-disk config.json, restarting monitoring if running. Never writes configPath -- it is purely hand-managed; cfg values take effect in memory only and are reapplied on every subsequent loadConfig()/ reloadConfig() call. Errors (via error()) if the resulting config is invalid (e.g. interval >= sustainSeconds) without applying any of it -- currently-running monitoring, if any, is left untouched.

ProcessWatcher:reloadConfig() Method #

Re-reads configPath from disk (e.g. after hand-editing it) and restarts monitoring if running.

ProcessWatcher:openConfig() Method #

Opens the config file in the user's default editor for JSON files.

ProcessWatcher:ignore(name) Method #

Snoozes alerts for name for config.snoozeHours and clears any current flag on it.

ProcessWatcher:kill(nameOrPid) Method #

Terminates a process by name (all PIDs currently aggregated under that name in the last sample) or by PID (numeric string/number). Returns true if any PID was targeted.

ProcessWatcher:status() Method #

Returns a human-readable summary of currently-flagged processes, processes still accumulating sustain ticks toward a flag, and the current top CPU/memory processes (used by the CLI).

ProcessWatcher:configSummary() Method #

Returns a one-line summary of the current thresholds/sustain/interval/allowlist/overrides config (used by the CLI).

ProcessWatcher:init() Method #

Called automatically by hs.loadSpoon(). Logs the loaded version.

ProcessWatcher:start() Method #

Begins periodic sampling and shows the menu bar icon.

ProcessWatcher:stop() Method #

Stops sampling and removes the menu bar icon.