ai didi

python - 调试监视器输出读数

转载 作者:行者123 更新时间:2023-12-04 19:06:17 24 4
gpt4 key购买 nike

每当使用 dbus-monitor 到达桌面通知时,我都会尝试触发 python 脚本或 shell 脚本
我以这种方式使用命令

dbus-monitor "interface='org.freedesktop.Notifications'" | grep --line-buffered "string" | xargs -I '{}'  python3 ./test.py {}
之后,我尝试使用从另一个终端发送桌面通知
-> 通知发送“你好”“世界”
上述自定义通知的输出是
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日志/监控机制。
有一篇好文章here关于 systemd dbus 和 python ..
在此 answer 中也有与您的问题非常相关的答案.也是。

关于python - 调试监视器输出读数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68794467/

24 4 0
文章推荐: python - 如何将python3设置为默认值
文章推荐: systemd - 设置 systemd journalctl 以忽略进程
文章推荐: r - 在一个图中绘制多个时间序列的 acf
文章推荐: python - pip3 install isal 在 Ubuntu 18 中失败,但在 Ubuntu 20 中运行良好(dockerized 场景)
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com