总线监视器输出读数



每当使用dbus-monitor到达桌面通知时,我试图触发python脚本或shell脚本

我是这样使用命令的

dbus-monitor "interface='org.freedesktop.Notifications'" | grep --line-buffered "string" | xargs -I '{}'  python3 ./test.py {}

之后,我正在尝试从另一个终端发送桌面通知→notify-send"hello"world">

上述自定义通知的输出为

string "notify-send"
string ""
string "hello"
string "world "
string "urgency"
string "notify-send"
string ""
string "hello"
string "world "
string "urgency"

但是如果这个命令的输出是10行,那么每一行都会调用python脚本。

,但我的期望是为每个通知调用python脚本一次,然后在一行中获得所有输出作为python脚本的参数。

利用systemddbus的集成是明智的。

使用systemd集成,程序员对dbus集成有更好的控制/传感器。还可以利用systemd日志/监视器机制。

这里有一篇关于systemd dbus with python的好文章。

在这个答案中也有与你的问题非常相关的答案。。

最新更新