You could try to use dbus-monitor (notifications are sent via dbus and you could capture them in some pyhton/c/rust/anything wrapper)
So the key command is:
dbus-monitor --session "destination='org.freedesktop.Notifications'"
See also some notification encoding:
https://specifications.freedesktop.org/notification-spec/1.3/protocol.html
Best regards