diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-23 15:01:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-23 15:01:14 +0200 |
| commit | 101c3e68aa18814dcc18a813958e1aa0f76bd7a7 (patch) | |
| tree | baa1d7082ae0385333c3ffe79d49871621b3e8d6 /shared/NotifyConfig.js | |
| parent | 231a7da0f9b4b8b007617fe12414c794f9374ee0 (diff) | |
| download | quickshell-101c3e68aa18814dcc18a813958e1aa0f76bd7a7.tar.gz quickshell-101c3e68aa18814dcc18a813958e1aa0f76bd7a7.zip | |
notify: one "balloon on screen" check, NotifyConfig.shown
The desktop companion needs to know when a balloon is showing in her
corner, and the rule lived inline in NotificationBalloon's visible
binding. It moves to the shared library so both shells ask the same
function: drawer, snooze, mute, DND, then expiry.
Shared files do not hot-reload through their links: restart the
notifications and desktop shells after pulling this.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'shared/NotifyConfig.js')
| -rw-r--r-- | shared/NotifyConfig.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/shared/NotifyConfig.js b/shared/NotifyConfig.js index 143168f..6fc98e6 100644 --- a/shared/NotifyConfig.js +++ b/shared/NotifyConfig.js @@ -71,6 +71,16 @@ function withheld(cfg, n, dnd) { return dnd && !(n.urgency === "critical" && cfg.dndPassCritical); } +// Whether a queued notification's balloon is on screen at `now`: the drawer +// and snooze withhold everything, then mute and DND, then its own expiry. +// The balloon shell and the desktop companion both ask this, so they cannot +// disagree about what is showing. +function shown(cfg, n, dnd, drawerOpen, snoozeUntil, now) { + if (drawerOpen || snoozeUntil > now) return false; + if (withheld(cfg, n, dnd)) return false; + return n.expires === 0 || now < n.expires; +} + // The file a balloon plays, "" for none: the app's suppress-sound wins, then // the app's own sound (notifyd resolved its hints), then the urgency's. function soundFor(cfg, n) { |
