My goal is to filter notifications coming from different applications (mainly from different browser window).
I found that with the help of the dbus-monitor I can write a small script that could filter the notification messages that I am interested in. The filter script is working well, but I have a small problem:
I am starting with the
dbus-monitor "interface='org.freedesktop.Notifications', destination=':1.40'"
command. I have to added the "destination=':1.40'" because on Ubuntu 20.04 I always got twice the same notification. The following output of
dbus-monitor --profile "interface='org.freedesktop.Notifications'"
demonstrate the reason:
type   timestamp               serial  sender  destination     path                            interface               member
#                                       in_reply_to
mc      1612194356.476927       7       :1.227  :1.56   /org/freedesktop/Notifications  org.freedesktop.Notifications   Notify
mc      1612194356.483161       188     :1.56   :1.40   /org/freedesktop/Notifications  org.freedesktop.Notifications   Notify
As you can see the sender :1.277 sends to :1.56 first than this will be the sender to :1.40 destination. (Simply notify-send hello test message was sent)
My script is working on that way, but every time system boot up, I have to check the destination number and modify my script accordingly to get worked.
I have two questions:
- how to discover the destination string automatically? (:1.40 in the above example)
- how to prevent system sending the same message twice? (If this question would be answered, than the question under point 1. became pointless.)
 
                        
I don't know if it directly solves your problem, but you can ask for details about a sender/destination using this command:
Assuming the sender/destination is still available, it will print something like:
Or if you want just the process id:
..which gives just:
These and others are documented here: https://dbus.freedesktop.org/doc/dbus-specification.html