Expand description
User-configurable shell commands that fire on scheduler events.
Hooks are off by default and gated behind a confirmation dialog
(see scheduler::commands::hooks::set_hooks). The threat model is
documented in docs/HOOKS.md — anyone with write access to
settings.json can run arbitrary code as the user, so the master
hooks_enabled toggle is the sole trust boundary.
Structs§
- Hook
- One configured hook: subscribe to
event, runcommandwhen it fires (ifenabled).commandis POSIX-style argv that we split withshell-words— no shell is involved, so pipes / redirects need an explicitsh -cwrapper. - Hook
Context - Per-call context populated by the scheduler. Fields show up as
$ENTRACTE_KIND,$ENTRACTE_DURATION_SECS,$ENTRACTE_OUTCOMEwhen the hook child runs; empty when not applicable to the event.
Enums§
- Hook
Event - The scheduler events a hook can subscribe to. Serialised as the
lowercase snake-case name (also the value passed in
$ENTRACTE_EVENT).
Constants§
- MAX_
HOOKS_ PER_ EVENT - Hard cap on hooks fired per event. A misconfigured (or malicious)
settings.jsoncould otherwise register thousands of entries and fork-bomb the host on every break boundary. 32 is well above any realistic per-event subscription count.
Functions§
- build_
env - Build the
(key, value)env vars handed to the hook child:ENTRACTE_EVENT,ENTRACTE_KIND,ENTRACTE_DURATION_SECS,ENTRACTE_OUTCOME. Missing fields are empty strings so consumers can shell-test them uniformly. - kind_
str 🔒 - matching_
hooks - Return the subset of hooks that should fire for
event. Returns empty when the masterhooks_enabledtoggle is off, regardless of per-hookenabledflags. - program_
log_ 🔒label - run_
hooks - Fire every matching hook for
event. Each child runs on its own std::thread and inherits stdio from/dev/null. Fire-and-forget: we never block on the child or capture its output. - run_
hooks_ with - Same as
run_hooksbut delegates spawning tospawn. The callback receives eachHook(already filtered byeventandenabled, and already truncated toMAX_HOOKS_PER_EVENT) plus the env vars that would be passed to its child. Used by tests to verify the cap without actually shelling out hundreds of processes. - spawn_
hook 🔒