首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >debus-监视器输出读数

debus-监视器输出读数
EN

Stack Overflow用户
提问于 2021-08-15 18:47:52
回答 1查看 86关注 0票数 0

每当使用dbus-monitor收到桌面通知时,我都会尝试触发python脚本或shell脚本。

我以这种方式使用该命令

代码语言:javascript
复制
dbus-monitor "interface='org.freedesktop.Notifications'" | grep --line-buffered "string" | xargs -I '{}'  python3 ./test.py {}

在那之后,我尝试使用-> notify从另一个终端发送桌面通知-发送"hello“"world”

上述自定义通知的输出为

代码语言:javascript
复制
string "notify-send"
string ""
string "hello"
string "world "
      string "urgency"
string "notify-send"
string ""
string "hello"
string "world "
      string "urgency"

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

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

EN

回答 1

Stack Overflow用户

发布于 2021-08-16 21:14:15

明智的做法是利用systemddbus的集成。

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

有一篇关于systemd dbus和python的好文章here

您的问题在answer中也有非常相关的答案。还有。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68794467

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档