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) {