Repository navigation
Conversation
Senders pick their own urgency and some misdeclare it. Chat apps mark
routine messages critical to force their way in front of you, and a
critical toast never expires, so those messages sit on screen until they
are dismissed by hand.
Urgency is read by every downstream decision — popup lifetime, the
do-not-disturb bypass, card styling, what lands in history — so correcting
it once, at ingest, keeps all of them honest instead of special-casing each
in turn. A `notifications.rules[]` block in shell.json now does that:
"notifications": {
"rules": [
{ "app": "Brave Origin", "urgency": "critical", "set": { "urgency": "normal" } },
{ "app": "Brave Origin", "summary~": "Alex|Sam", "set": { "urgency": "critical" } }
]
}
A rule filters on the fields it names (app, appIcon, summary, body and the
incoming urgency) and every one of them has to match; a `~` suffix makes the
value a regular expression, following mako's `summary~` convention. Rules
apply in order and the last match wins, so a broad rule can be narrowed by a
later one. dunst has carried the same capability for years, where rules match
appname/desktop_entry and can set urgency directly.
The mapping lands in snapshotOf(), which every snapshot funnels through,
including the replaces_id update path. shouldBypassDnd() now reads the
snapshot rather than the live notification, so a sender mapped below critical
stops bypassing do-not-disturb too — otherwise the mapping would only half
apply.
A rule whose regular expression does not compile is skipped rather than
propagated, so a typo in shell.json cannot take a notification down with it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLxWtBaFee73f3cnkcA4iu
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Senders pick their own urgency and some misdeclare it. A chat app that marks every message critical gets a toast that never expires, because
durationFor()returns0forNotificationUrgency.Critical. The message then sits on screen until it is dismissed by hand.Urgency is not read in one place — popup lifetime, the do-not-disturb bypass, card styling and what lands in history all consult it. So rather than special-casing duration, this corrects urgency once at ingest and lets every downstream decision stay honest.
What it adds
A top-level
notifications.rules[]block inshell.json:{ "notifications": { "rules": [ { "app": "Brave Origin", "urgency": "critical", "set": { "urgency": "normal" } }, { "app": "Brave Origin", "summary~": "Alex|Sam", "set": { "urgency": "critical" } } ] } }A rule filters on the fields it names —
app,appIcon,summary,body, and the incomingurgency— and every field it names has to match. A~suffix makes the value a regular expression instead of exact text, following mako’ssummary~/body~convention. What changes goes inset. Rules apply in order and the last match wins, so the pair above reads as “everything that browser marks critical is really only normal, except messages from these two people”.Read straight off
shellConfig, so the rules hot-reload with the rest ofshell.json.Prior art
dunst has carried this for years: its rules match
appname/desktop_entry/msg_urgencyandurgencyis among the attributes they can set. mako matches on a comparable field set with POSIX regex onsummary/body. Both converged on declarative multi-field criteria rather than an expression language, which is what this follows.Implementation notes
snapshotOf(). Every snapshot funnels through it,replacementSnapshot()included, so notifications updated in place viareplaces_idare mapped on the same path.shouldBypassDnd()now takes the snapshot instead of the live notification, so it reads the mapped urgency. Without this a sender mapped below critical would keep bypassing do-not-disturb and the mapping would only half apply. Its four existing assertions were updated to passapprather thanappName.isEphemeral()deliberately still reads the live object: it looks at thetransienthint and the app name, neither of which the mapping touches.shell.jsoncannot take a notification down with it.Testing
test/shell.d/notifications-test.shcovers the pure logic: matching by app and by regex, AND across matchers, later-rule-wins, an unknown urgency name, absent rules, and a malformed pattern. Three further assertions check theService.qmlwiring the way that file already checks the rest of the service../test/allpasses exceptconfig-test.sh,snapper-test.shandunowned-system-paths-test.sh, which fail identically on a clean checkout here (they want a siblingomarchy-pkgscheckout and a real system layout).Also verified end to end on a running Omarchy 4.0.2 desktop, with the rules above in
shell.json: a critical from the browser expired on the normal 8s timer, a matching summary stayed pinned, an unmapped CLI critical stayed pinned, and anotify-sendcritical mapped down to normal correctly stopped bypassing do-not-disturb.Relationship to existing work
Related to #9361, which reports that critical notifications never auto-expire. This does not close it: that report is about Omarchy’s own crash toasts, which are genuinely critical, and remapping those would be the wrong fix. A bounded default for critical, as the issue suggests, remains a separate change.
Orthogonal to #9010 and #8980, which both add a visible dismiss control. This touches neither the card nor
durationFor().🤖 Generated with Claude Code
https://claude.ai/code/session_01DLxWtBaFee73f3cnkcA4iu