repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

notifications: progress bar from int:value hint

77c266d839cf0b9bbe7a0aa1c2371b9deecf6b41

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Support the KDE/Plasma de-facto progress hint (hints.value, 0-100). The
service reads it live off the native object so replace-in-place progress
updates flow through; the card renders a real progress bar (full card) and
the toast's bottom bar shows progress instead of the auto-dismiss drain
when a value is present.

Progress toasts persist while running rather than draining out, and
auto-dismiss ~1.5s after reaching 100% — aligning "done" with the toast
disappearing instead of leaving a mismatched countdown tail. History keeps
the completed notification.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (3)

quickshell/nuguland/NotificationCard.qml

Modified
21 21 // image://icon//abs/path -> file:///abs/path so plain Image keeps true aspect
22 22 readonly property string photoSource: !imageIsPhoto ? "" : (photoCandidate.indexOf("image://icon//") === 0 ? "file://" + photoCandidate.substring(13) : photoCandidate)
24 + // KDE/Plasma progress hint (0-100); -1 when the notification has no value.
25 + readonly property int progress: modelData.value !== undefined ? Number(modelData.value) : -1
26 + readonly property bool hasProgress: progress >= 0
24 28 // local text styling, mirrors PopoutHost NuguText variants
25 29 component CardText: Text {
26 30 required property QtObject theme
174 178 sourceSize.width: 220
181 + // content progress (KDE int:value); distinct from the toast's
182 + // auto-dismiss drain. Full card only — the toast shows it inline.
183 + Item {
184 + width: parent.width
185 + height: card.hasProgress && !card.compact ? 8 : 0
186 + visible: card.hasProgress && !card.compact
187 + Rectangle {
188 + anchors.verticalCenter: parent.verticalCenter
189 + width: parent.width
190 + height: 4
191 + radius: 2
192 + color: card.theme ? card.theme.withAlpha(card.theme.ui.minor, 0.25) : "transparent"
193 + Rectangle {
194 + width: parent.width * Math.max(0, Math.min(100, card.progress)) / 100
195 + height: parent.height
196 + radius: 2
197 + color: card.theme ? card.theme.ui.accent : "transparent"
198 + Behavior on width { NumberAnimation { duration: card.theme && card.theme.lowPowerMode ? 0 : 200 } }
177 203 Flow {
178 204 width: parent.width
179 205 spacing: 6

quickshell/nuguland/Notifications.qml

Modified
103 103 "expireTimeout": Number(record.expireTimeout !== undefined ? record.expireTimeout : -1),
104 104 "transient": !!record.transient,
105 105 "actions": actions,
106 + // KDE/Plasma de-facto progress hint (int:value 0-100); -1 = absent.
107 + "value": Number(record.value !== undefined ? record.value : -1),
106 108 "popup": !(dnd || popupInhibition),
107 109 "closed": false,
108 110 "read": false,
116 118 return !dndOn;
121 + // KDE/Plasma progress hint: hints.value (0-100), -1 when absent. Read live
122 + // off the native object so replace-in-place progress updates flow through.
123 + function hintValue(notification) {
124 + const h = notification && notification.hints ? notification.hints : null;
125 + return h && h.value !== undefined && h.value !== null ? Number(h.value) : -1;
119 128 function toastTimeoutMs(row) {
120 129 if (row.urgency === "critical" || Number(row.expireTimeout) === 0)
121 130 return 0;
196 205 "urgency": notification.urgency,
197 206 "expireTimeout": notification.expireTimeout,
198 207 "transient": notification.transient,
199 - "actions": notification.actions || []
208 + "actions": notification.actions || [],
209 + "value": hintValue(notification)
201 211 const eligible = toastEligible(row, dnd);
202 212 // only retain the live native object if something will render it:
275 285 "appName": n.appName || row.appName,
276 286 "appIcon": n.appIcon || row.appIcon,
277 287 "image": n.image || row.image,
288 + "value": hintValue(n),
278 289 "urgency": urgencyName(n.urgency)

quickshell/nuguland/shell.qml

Modified
322 322 readonly property real toastTotal: toastWrap.modelData.timeoutMs || 0
323 323 readonly property real toastExpiry: toastWrap.modelData.expiresAt || 0
324 324 readonly property real toastRemaining: Math.max(0, toastExpiry - Date.now())
325 + readonly property int toastProgress: toastWrap.modelData.value !== undefined ? Number(toastWrap.modelData.value) : -1
326 + readonly property bool toastHasProgress: toastProgress >= 0
328 + // Progress toasts persist until complete (no drain
329 + // dismissal); plain toasts auto-dismiss at expiry.
325 330 Timer {
326 - running: toastWrap.toastExpiry > 0
331 + running: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress
327 332 interval: Math.max(1, toastWrap.toastRemaining)
328 333 repeat: false
329 334 onTriggered: notifications.dismissToast(String(toastWrap.modelData.id))
331 - // auto-dismiss countdown: a thin bar drains across the
332 - // bottom edge over the toast's remaining lifetime
333 - // (sticky/critical have expiresAt 0 -> hidden;
334 - // lowPowerMode -> static).
336 + // Progress complete: auto-dismiss shortly after 100%.
337 + Timer {
338 + running: toastWrap.toastHasProgress && toastWrap.toastProgress >= 100
339 + interval: 1500
340 + repeat: false
341 + onTriggered: notifications.dismissToast(String(toastWrap.modelData.id))
343 + // bottom bar: content progress when the toast carries
344 + // a value hint, otherwise the auto-dismiss drain.
335 345 Rectangle {
336 - visible: toastWrap.toastExpiry > 0
346 + visible: toastWrap.toastHasProgress
347 + anchors.left: toastCard.left
348 + anchors.bottom: toastCard.bottom
349 + anchors.leftMargin: 12
350 + anchors.bottomMargin: 4
351 + height: 2
352 + radius: 1
353 + color: nuguTheme ? nuguTheme.ui.accent : "transparent"
354 + width: (toastCard.width - 24) * Math.max(0, Math.min(100, toastWrap.toastProgress)) / 100
355 + Behavior on width { NumberAnimation { duration: nuguTheme && nuguTheme.lowPowerMode ? 0 : 200 } }
357 + Rectangle {
358 + visible: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress
337 359 anchors.left: toastCard.left
338 360 anchors.bottom: toastCard.bottom
339 361 anchors.leftMargin: 12
343 365 color: nuguTheme ? nuguTheme.withAlpha(nuguTheme.ui.accent, 0.55) : "transparent"
344 366 width: (toastCard.width - 24) * (toastWrap.toastTotal > 0 ? toastWrap.toastRemaining / toastWrap.toastTotal : 1)
345 367 NumberAnimation on width {
346 - running: toastWrap.toastExpiry > 0 && !(nuguTheme && nuguTheme.lowPowerMode)
368 + running: toastWrap.toastExpiry > 0 && !toastWrap.toastHasProgress && !(nuguTheme && nuguTheme.lowPowerMode)
348 370 duration: Math.max(1, toastWrap.toastRemaining)