Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Context Rules

A "when X then Y" automation engine for Omarchy v4 ("Quattro"): your desktop reacts to what you are doing — screensharing, gaming, the hour, the power source — without you touching a toggle.

While a trigger holds, its actions are asserted; when it clears, the engine restores each actuator to exactly the state it had before the rule fired. If you had DND on before a screenshare started, it stays on after the call ends.

Triggers

when Fires while… Extra fields
screenshare any app is casting the screen (Hyprland screencast event)
window-class the focused window's app id matches an anchored regex match
time the clock is inside a window (may wrap midnight) from, to ("HH:MM")
on-battery the machine runs on battery (UPower)

Actions

dnd, night-light, stay-awake, game-mode (shared flag with community.game-mode), power-profile:performance / power-profile:balanced / power-profile:power-saver.

Rules

~/.config/omarchy/context-rules.json — watched, so edits apply immediately, no restart. With no file, one safe default applies: screenshare → DND + stay awake.

{
  "rules": [
    { "when": "screenshare", "do": ["dnd", "stay-awake"] },
    { "when": "window-class", "match": "steam_app_.*|gamescope", "do": ["game-mode", "power-profile:performance"] },
    { "when": "time", "from": "21:00", "to": "07:00", "do": ["night-light"] }
  ]
}

Invalid rules are dropped; {"rules": []} disables everything explicitly.

Bar chip

The optional bar widget (󱐋) is lit while any rule is asserting, dimmed while the engine is paused; clicking pauses/resumes the engine (persisted in ~/.local/state/omarchy/settings/context-rules.json). Scriptable:

omarchy-shell community.context-rules status | enable | disable

Install

omarchy plugin add https://github.com/devmobasa/omarchy-context-rules --enable

Notes and caveats

  • Omarchy's battery service already switches power profiles on AC/battery changes. An on-batterypower-profile:* rule will contend with it; prefer leaving power profiles to rules that key on something else (like a game launching).
  • Restores happen from an in-memory snapshot. If the shell restarts while a rule is asserted, the engine re-asserts on startup but the pre-rule snapshot is gone — it will then restore to the asserted value. Rare and self-corrects the next time you flip the control by hand.
  • window-class matches the Wayland app id of the focused window (hyprctl clients .class for native windows).

Tests

./test/all   # node model + contract + static QML checks, manifest, qmllint

License

MIT

About

When-X-then-Y desktop automation: screenshare, focused app, time, and battery triggers driving DND, night light, stay awake, game mode, and power profiles

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages