repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

notifications: action-icons + inline reply support

dfb1b5cf00aa05d483b211953a3357c0f8cd7af9

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Two freedesktop capabilities the server advertised or could advertise but
did not deliver:

- action-icons: the server already advertised actionIconsSupported, but
  action buttons rendered text only. Thread hasActionIcons through the row;
  when set, an action's identifier is a freedesktop icon name, so render it
  as an IconImage beside the label.

- inline reply: flip inlineReplySupported on (changes GetCapabilities for
  all clients). Thread hasInlineReply/inlineReplyPlaceholder through the row;
  render a quick-reply TextInput in the full card when present; Enter routes
  to the native sendInlineReply(). sendInlineReply already destroys the
  native object, so closeNotification gains a skipNativeDismiss path to avoid
  'Cannot close destroyed notification'. Added a notificationsReply IPC
  handler as the headless control surface.

Verified: GetCapabilities lists action-icons + inline-reply; a gdbus
notification with hasInlineReply surfaces in state with the placeholder; an
IPC reply emits NotificationReplied(id,'omw') + NotificationClosed on the
bus with no errors; action-icons notification carries icon=<name> on the
server-action row. selftest green.

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

Changed files (4)

+130 / −11 text lines

Diff layout

quickshell/nuguland/NotificationCard.qml

Modified

+65 / −6 text lines

99 property bool compact: false
1010 signal dismiss(string id)
1111 signal invokeAction(string id, string actionId)
12 signal sendReply(string id, string text)
14 readonly property bool canReply: !compact && !!modelData.hasInlineReply
1316 // notify-send funnels BOTH named freedesktop icons and attached photos into
1417 // `image` as an image://icon/ provider URL (appIcon stays empty). Split them:
221224 delegate: Rectangle {
222225 id: actionBtn
223226 required property var modelData
227 // action-icons: identifier doubles as a freedesktop icon name.
228 readonly property string actIcon: String(actionBtn.modelData.icon || "")
224229 height: 26
225 width: Math.max(58, actLabel.implicitWidth + 18)
230 width: Math.max(58, actRow.implicitWidth + 18)
226231 radius: 8
227232 color: {
228233 if (!card.theme)
233238 return card.theme.withAlpha(card.theme.ui.accent, 0.24);
234239 return card.theme.withAlpha(card.theme.ui.accent, 0.14);
235240 }
236 CardText {
237 id: actLabel
241 Row {
242 id: actRow
238243 anchors.centerIn: parent
239 theme: card.theme
240 variant: "meta"
241 text: actionBtn.modelData.label || "act"
244 spacing: 5
245 IconImage {
246 anchors.verticalCenter: parent.verticalCenter
247 width: 16
248 height: 16
249 source: actionBtn.actIcon
250 visible: actionBtn.actIcon.length > 0
251 }
252 CardText {
253 id: actLabel
254 anchors.verticalCenter: parent.verticalCenter
255 theme: card.theme
256 variant: "meta"
257 text: actionBtn.modelData.label || "act"
258 }
242259 }
243260 MouseArea {
244261 id: actArea
252269 }
253270 }
254271 }
273 // inline reply (chat apps advertising hasInlineReply): a quick
274 // text field; Enter sends via sendInlineReply() and clears.
275 Rectangle {
276 width: parent.width
277 height: card.canReply ? 30 : 0
278 visible: card.canReply
279 radius: 10
280 color: card.theme ? card.theme.withAlpha(card.theme.ui.minor, 0.14) : "transparent"
281 border.width: replyInput.activeFocus ? 1 : 0
282 border.color: card.theme ? card.theme.ui.accent : "transparent"
284 TextInput {
285 id: replyInput
286 anchors.fill: parent
287 anchors.leftMargin: 10
288 anchors.rightMargin: 10
289 verticalAlignment: TextInput.AlignVCenter
290 color: card.theme ? card.theme.content.normal : "white"
291 selectionColor: card.theme ? card.theme.ui.focus : "#ffffff"
292 selectedTextColor: card.theme ? card.theme.content.backdrop : "black"
293 font.family: "IBM Plex Sans"
294 font.pixelSize: 13
295 clip: true
296 onAccepted: {
297 if (text.length > 0) {
298 card.sendReply(String(card.modelData.id), text);
299 text = "";
300 }
301 }
302 }
304 CardText {
305 anchors.left: parent.left
306 anchors.leftMargin: 10
307 anchors.verticalCenter: parent.verticalCenter
308 visible: replyInput.text.length === 0
309 theme: card.theme
310 variant: "meta"
311 text: card.modelData.inlineReplyPlaceholder || "Reply…"
312 }
313 }
255314 }
257316 Item {

quickshell/nuguland/Notifications.qml

Modified

+56 / −5 text lines

107107 "value": Number(record.value !== undefined ? record.value : -1),
108108 // resident: keep the notification after an action is invoked.
109109 "resident": !!record.resident,
110 // action-icons: action identifiers double as freedesktop icon names.
111 "hasActionIcons": !!record.hasActionIcons,
112 // inline reply (chat apps): a quick-reply field + sendInlineReply().
113 "hasInlineReply": !!record.hasInlineReply,
114 "inlineReplyPlaceholder": String(record.inlineReplyPlaceholder || ""),
110115 "popup": !(dnd || popupInhibition),
111116 "closed": false,
112117 "read": false,
223228 "transient": notification.transient,
224229 "actions": notification.actions || [],
225230 "value": hintValue(notification),
226 "resident": notification.resident
231 "resident": notification.resident,
232 "hasActionIcons": notification.hasActionIcons,
233 "hasInlineReply": notification.hasInlineReply,
234 "inlineReplyPlaceholder": notification.inlineReplyPlaceholder
227235 });
228236 const eligible = toastEligible(row, dnd);
229237 // only retain the live native object if something will render it:
267275 }];
268276 const serverActions = notification.actions || [];
269277 for (let i = 0; i < serverActions.length; i++) {
278 const aid = serverActions[i].id || serverActions[i].identifier || `action-${i}`;
270279 rows.push({
271 "id": serverActions[i].id || serverActions[i].identifier || `action-${i}`,
280 "id": aid,
272281 "kind": "server-action",
273282 "label": serverActions[i].label || serverActions[i].text || "Action",
283 // with action-icons, the identifier IS a freedesktop icon name.
284 "icon": notification.hasActionIcons ? aid : "",
274285 "route": "Notifications.qml"
275286 });
276287 }
445456 return stateJson();
446457 }
448 function closeNotification(row) {
459 function closeNotification(row, skipNativeDismiss) {
449460 if (!row || row.closed)
450461 return ;
453464 row.removalLifecycleLock = removalLifecycleLock;
454465 unreadCount = Math.max(0, unreadCount - 1);
455466 const nativeNotification = nativeNotifications[String(row.nativeId || row.id)];
456 if (nativeActionRoute && nativeNotification && nativeNotification.dismiss)
467 // sendInlineReply() already destroys the native object — dismissing it
468 // again throws "Cannot close destroyed notification". Callers that know
469 // the native is gone pass skipNativeDismiss.
470 if (!skipNativeDismiss && nativeActionRoute && nativeNotification && nativeNotification.dismiss)
457471 nativeNotification.dismiss();
459473 activeToasts = activeToasts.filter((x) => x !== String(row.id));
533547 return stateJson();
534548 }
550 // inline reply: route the text to the native object's sendInlineReply().
551 // freedesktop convention closes the notification after a reply unless it
552 // declared itself resident.
553 function sendReply(notificationId, text) {
554 const id = String(notificationId);
555 const body = String(text || "");
556 for (let i = 0; i < notifications.length; i++) {
557 const n = notifications[i];
558 if (n.id !== id)
559 continue;
561 let sent = false;
562 const native = nativeNotifications[String(n.nativeId || n.id)];
563 if (body.length > 0 && native && native.hasInlineReply && native.sendInlineReply) {
564 native.sendInlineReply(body);
565 sent = true;
566 }
567 lastAction = {
568 "kind": "inline-reply",
569 "id": id,
570 "sent": sent,
571 "resident": !!n.resident,
572 "route": "Notifications.qml"
573 };
574 if (sent && !n.resident)
575 closeNotification(n, true);
576 notifications = notifications.slice(0);
577 return stateJson();
578 }
579 lastAction = {
580 "kind": "missing",
581 "id": id,
582 "route": "Notifications.qml"
583 };
584 return stateJson();
585 }
536587 function toggleGroup(appName) {
537588 const app = String(appName);
538589 const expanded = expandedGroups.indexOf(app) < 0;
575626 actionsSupported: true
576627 actionIconsSupported: true
577628 imageSupported: true
578 inlineReplySupported: false
629 inlineReplySupported: true
579630 onNotification: (notification) => {
580631 return root.acceptNativeNotification(notification);
581632 }

quickshell/nuguland/PopoutHost.qml

Modified

+5 / −0 text lines

12501250 if (notificationService)
12511251 notificationService.runAction(id, actionId);
1253 function sendReply(id, text) {
1254 if (notificationService)
1255 notificationService.sendReply(id, text);
1256 }
12531257 function toggleGroup(appName) {
12541258 if (notificationService)
12551259 notificationService.toggleGroup(appName);
13971401 modelData: cardWrap.modelData
13981402 onDismiss: (id) => root.runAction(id, "close")
13991403 onInvokeAction: (id, actionId) => root.runAction(id, actionId)
1404 onSendReply: (id, text) => root.sendReply(id, text)

quickshell/nuguland/shell.qml

Modified

+4 / −0 text lines

631631 return notifications.runAction(id, actionId);
632632 }
634 function notificationsReply(id: string, text: string) : string {
635 return notifications.sendReply(id, text);
636 }
634638 function notificationsToggleGroup(appName: string) : string {
635639 return notifications.toggleGroup(appName);
636640 }