phosphor-rules

Unified window/context rule engine with one match language and cache.

Phosphor's single rule engine: one composable match-expression language, one pluggable action set, one serialization format, and one evaluation pipeline with a match cache. Both the KWin effect and the daemon link this one implementation so match code lives in exactly one place. RuleEvaluator::resolve() walks the rule set in descending priority and accumulates the first action that fills each slot, and RuleSet reads and writes rules.json at a fixed schema version, dropping malformed rules with a diagnostic. Actions are slot-based descriptors registered in an ActionRegistry, so a new action type — setting a scrolling template, pinning a strip axis — is a registration rather than an engine change.

Full API →

Key types

Rule
A single rule: { id, name, enabled, priority, match, actions, managed }.
MatchExpression
Composable leaf/composite predicate tree with JSON serialization and cached regex.
RuleEvaluator
Descending-priority resolution into resolved action slots, backed by a (windowId, revision) match cache.
RuleSet
Ordered rule collection with a monotonic revision and rules.json I/O.
RuleAction
Pluggable slot-based action descriptors plus the ActionRegistry they register into.
ContextRuleBridge
Feeds mode / desktop / activity context into the attribute bag rules match against.

Dependencies

See also

References