dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Reviews Threads Compare Notes Search Review guide CI runs notifications: activeToasts model with DND/critical/transient lifecycle + dismissToasts 5526ad6f36c31bf1d35435ce2675752ba53c0a24
Oliver Jan Krylow <oliver@bugabinga.net > · 26 Jun 2026
unsigned
Browse files Compare with HEAD
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Changed files (2) Diff layout Auto Unified Split
quickshell/nuguland/Notifications.qml Modified +70 / −2 text lines
13 13 property var nativeNotifications: ({ property var nativeNotifications: ({15 15 property var expandedGroups: [] property var expandedGroups: []
16 + property var activeToasts: []17 + property var toastById: ({})18 + readonly property int defaultToastTimeoutMs: 5000 16 19 property var pointerTrace: [] property var pointerTrace: []17 20 property var lastAction: ({ property var lastAction: ({111 114 "body" : record. body || "" , "body" : record. body || "" ,112 115 "time" : Number (record. time || Date . now()), "time" : Number (record. time || Date . now()),113 116 "urgency" : urgencyName (record. urgency || "normal" ), "urgency" : urgencyName (record. urgency || "normal" ),
117 + "expireTimeout" : Number (record. expireTimeout !== undefined ? record. expireTimeout : -1 ),118 + "transient" : !! record. transient,114 119 "actions" : actions, "actions" : actions,115 120 "popup" : ! (dnd || popupInhibition), "popup" : ! (dnd || popupInhibition),116 121 "closed" : false , "closed" : false ,
127 + function toastEligible (row, dndOn) {128 + if (row. urgency === "critical" )133 + function toastTimeoutMs (row) {134 + if (row. urgency === "critical" || Number (row. expireTimeout) === 0 )136 + const et = Number (row. expireTimeout);137 + return et > 0 ? Math . round(et * 1000 ) : defaultToastTimeoutMs;122 140 function mergeRow (list, row) { function mergeRow (list, row) {123 141 const next = (list || []). slice(); const next = (list || []). slice();124 142 for (let i = 0 ; i < next. length; i++ ) { for (let i = 0 ; i < next. length; i++ ) {162 180 rlist = mergeRow (rlist, {"id" : "9" , "summary" : "x" , "closed" : false , "read" : true }); rlist = mergeRow (rlist, {"id" : "9" , "summary" : "x" , "closed" : false , "read" : true });163 181 rlist = mergeRow (rlist, {"id" : "9" , "summary" : "y" , "closed" : false , "read" : false }); rlist = mergeRow (rlist, {"id" : "9" , "summary" : "y" , "closed" : false , "read" : false });164 182 expect (rlist[0 ]. read === true , "replace-by-id should preserve original read flag" ); expect (rlist[0 ]. read === true , "replace-by-id should preserve original read flag" );
183 + expect (toastEligible({"urgency" : "normal" }, false ) === true , "normal toasts when DND off" );184 + expect (toastEligible({"urgency" : "normal" }, true ) === false , "normal suppressed under DND" );185 + expect (toastEligible({"urgency" : "critical" }, true ) === true , "critical bypasses DND" );186 + expect (toastTimeoutMs({"urgency" : "critical" , "expireTimeout" : 5 }) === 0 , "critical is sticky" );187 + expect (toastTimeoutMs({"urgency" : "normal" , "expireTimeout" : 0 }) === 0 , "expireTimeout 0 is sticky" );188 + expect (toastTimeoutMs({"urgency" : "normal" , "expireTimeout" : -1 }) === defaultToastTimeoutMs, "default timeout" );166 190 "pass" : failures. length === 0 , "pass" : failures. length === 0 ,167 191 "failures" : failures "failures" : failures188 212 "body" : notification. body, "body" : notification. body,189 213 "time" : Date . now (), "time" : Date . now (),190 214 "urgency" : notification. urgency, "urgency" : notification. urgency,
215 + "expireTimeout" : notification. expireTimeout,216 + "transient" : notification. transient,191 217 "actions" : notification. actions || [] "actions" : notification. actions || []221 + if (toastEligible(row, dnd)) {222 + const map = Object . assign({}, toastById);225 + activeToasts = activeToasts. filter((x) => x !== row. id). concat([row. id]);194 227 lastAction = { lastAction = {195 228 "kind" : "native-notification" , "kind" : "native-notification" ,196 229 "id" : id, "id" : id,
283 + function activeToastRows () {285 + for (let t = 0 ; t < activeToasts. length; t++ ) {286 + const stored = toastById[activeToasts[t]];289 + const row = liveRow(stored);291 + rows. push(Object . assign({}, row, {292 + "actionRows" : actionRows(row),293 + "timeoutMs" : toastTimeoutMs(row)299 + function dismissToast (id) {300 + activeToasts = activeToasts. filter((x) => x !== String (id));301 + const map = Object . assign({}, toastById);302 + delete map[String (id)];307 + function dismissToasts () {250 313 function groups () { function groups () {251 314 const byApp = ({ const byApp = ({378 441 "discardAll" : true , "discardAll" : true ,379 442 "removalLifecycleLock" : removalLifecycleLock, "removalLifecycleLock" : removalLifecycleLock,380 443 "pointerTrace" : pointerTrace, "pointerTrace" : pointerTrace,381 - "lastAction" : lastAction444 + "lastAction" : lastAction, 445 + "activeToasts" : activeToastRows ()406 470 if (nativeActionRoute && nativeNotification && nativeNotification. dismiss) if (nativeActionRoute && nativeNotification && nativeNotification. dismiss)407 471 nativeNotification. dismiss (); nativeNotification. dismiss ();
473 + activeToasts = activeToasts. filter ((x) => x !== String (row. id));474 + const tmap = Object . assign ({}, toastById);475 + delete tmap[String (row. id)];411 479 function runAction (notificationId, actionId) { function runAction (notificationId, actionId) {quickshell/nuguland/shell.qml Modified +4 / −0 text lines
528 528 return JSON . stringify (notifications. selfTest()); return JSON . stringify (notifications. selfTest());
531 + function notificationsDismissToasts () : string {532 + return notifications. dismissToasts();531 535 function trayWidgetState (attention: bool, active: bool) : string { function trayWidgetState (attention: bool, active: bool) : string {532 536 return tray. widgetState(attention, active); return tray. widgetState(attention, active);