From e2a0b37d03c557fb02acd73c7d664d0c81cf7f32 Mon Sep 17 00:00:00 2001 From: Mario Mohar <76663003+Mario-Mohar@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:29:21 +0200 Subject: [PATCH] notifications: add invokeLast ipc to run the newest notification's default action (#3734) * notifications: add invokeLast ipc to run the newest notification's default action * notifications: drop the invokeLast test file --- quickshell/Modals/NotificationModal.qml | 6 ++++++ quickshell/Services/NotificationService.qml | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/quickshell/Modals/NotificationModal.qml b/quickshell/Modals/NotificationModal.qml index b77adf63c..1d2a95973 100644 --- a/quickshell/Modals/NotificationModal.qml +++ b/quickshell/Modals/NotificationModal.qml @@ -190,6 +190,12 @@ DModal { return "NOTIFICATION_DISMISS_SUCCESS"; } + function invokeLast(): string { + if (!NotificationService.invokeLastNotification()) + return "NOTIFICATION_INVOKE_NO_ACTION"; + return "NOTIFICATION_INVOKE_SUCCESS"; + } + target: "notifications" } diff --git a/quickshell/Services/NotificationService.qml b/quickshell/Services/NotificationService.qml index d888df85f..6779b9fc6 100644 --- a/quickshell/Services/NotificationService.qml +++ b/quickshell/Services/NotificationService.qml @@ -1049,6 +1049,17 @@ Singleton { dismissNotification(w); } + function invokeLastNotification() { + const w = notifications[notifications.length - 1]; + const actions = w?.actions || []; + const action = actions.find(a => a.identifier === "default") || actions[0]; + if (!action?.invoke) + return false; + action.invoke(); + dismissNotification(w); + return true; + } + function dismissAllPopups() { for (const w of visibleNotifications) { if (w) {