参考文献:
书签:
org.freedesktop.Notifications.CloseNotification(uint id)可以通过DBus触发和调用吗?
目前,这个脚本
dbus-monitor "interface='org.freedesktop.Notifications'" | \
grep --line-buffered "member=Notify" | \
sed -u -e 's/.*/killall notify-osd/g' | \
bash将杀死所有挂起的通知。
最好使用org.freedesktop.Notifications.CloseNotification(uint id)来细化要取消的特定目标OSD通知。是否有一个接口方法可以把它放在(in?)上?当发生特定的通知事件时要触发的DBus?
该方法将需要获取notify作为CloseNotification(uint id)的参数。或者,
qdbus org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications.CloseNotification(uint id)如果可以确定(uint id)参数,则可以从shell中使用。实际的命令语法将使用整数来代替(uint id)。
也许首先要问的一个更好的问题是“如何找到通知的DBus地址?”
这两种方法都没有正确识别:
gdbus monitor --session --dest org.freedesktop.Notifications返回
The name org.freedesktop.Notifications is owned by :1.130
...或
dbus-monitor "interface='org.freedesktop.Notifications'"返回
... string ":1.340" ...事后看来,前一个问题“通知的(uint id)是如何找到的?”对于另一个问题的先前的回答是否很棘手:
https://askubuntu.com/a/186311/89468
提供详细信息,以便可以使用以下任何一种方法:
gdbus call --session --dest org.freedesktop.DBus \
--object-path / \
--method org.freedesktop.DBus.GetConnectionUnixProcessID :1.16返回:
(uint32 8957,)或
qdbus --literal --session org.freedesktop.DBus \
/ \
org.freedesktop.DBus.GetConnectionUnixProcessID :1.16返回:
8957弹出通知-OSD涂鸦将以以下方式被击败:
qdbus org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications.CloseNotification \
$(qdbus --literal --session \
org.freedesktop.DBus \
/ \
org.freedesktop.DBus.GetConnectionUnixProcessID :?.??? )“诀窍”是找到:?.??? DBus地址。
发布于 2012-09-19 19:38:29
CloseNotification方法由规格说明定义为D总线方法.然而,它只声明ID是唯一的,非零的,并且小于MAXINT。它不要求ID是调用进程的PID。在成功调用该方法之前,您需要一种获得该ID的方法。
发布于 2013-04-12 17:27:16
我知道我有点晚了,但今天我自己也遇到了这个问题,这可能对其他人有用!
首先,安装一个修补好的libnotify-bin,它支持-p选项来打印通知id:
sudo apt-add-repository ppa:izx/askubuntu
sudo apt-get update
sudo apt-get install libnotify-bin现在有一个示例脚本,它发送通知而不超时,然后在某个命令完成后关闭通知(在本例中,只睡5秒):
notify-send 'Message...' -i dialog-information \
-t 0 -h int:transient:1 \
-p >/tmp/notification_id
sleep 5
qdbus org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications.CloseNotification \
$(cat /tmp/notification_id)https://askubuntu.com/questions/190406
复制相似问题