How to read system-wide notifications on Manjaro Linux?

让人想犯罪 __ 提交于 2020-01-25 11:00:07

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/58278669/how-to-read-system-wide-notifications-on-manjaro-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!