Search code examples
pythonnotify

How to read system-wide notifications on Manjaro Linux?


I am trying to write a Python script to get the info from a system notification, and performs actions after that.

How can I read the system wide notification text?

I am using Notify to create and send notifications, but I'm unable to retrieve that data from another script.

This is my 'create' code

import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
Notify.init("App Name")
Notify.Notification.new("Hi").show()

Solution

  • The notifications go over DBus from the program to another program which displays them. You can capture the notifications by monitoring the DBus for all calls to the method org.freedesktop.Notifications.Notify via:

    dbus-monitor interface=org.freedesktop.Notifications,member=Notify
    

    This can also be done via the bindings with eavesdrop='true' added to that match string.