... but it looks like a lot of work ...
It's not really too bad, at least for a crude generic solution.
Here is a copy of the details from my answer to last year's (sept 2012) post in
How to disable notification from network-manager.
dbus-monitor "interface='org.freedesktop.Notifications'" \
| grep --line-buffered 'string "NetworkManager"' \
| sed -u -e 's/.*/killall notify-osd/g' \
| bash
Replace string "NetworkManager"
with the desired RE to determine blocking.
To get an idea of what RE pattern match to look for run:
dbus-monitor "interface='org.freedesktop.Notifications'"
and look at the output while the notifications are popping-up.
ie. to remove notify-send
messages also, use this grep
line instead:
| grep --line-buffered 'string "NetworkManager"\|string "notify-send"' \
Caveat:
killall notify-osd
is non-discriminating and completely wipes the notification stack of any pending messages irregardless of whether NetworkManager
or notify-send
is the notifying agent.
An "honest" solution needs to account for possible race conditions when between determining a notification purge is needed and then doing doing it, another notification comes in that should pop-up and not be purged with the rest.
Also, if notifications are pending when the offending one to be blocked comes in, they will all be purged. This situation can at least be solved by making a copy of the dbus
pending notifications and then reissue the desired ones with notify-send
after the purge.
This is a bit of manually labour intensive work!
Ideally, the direct dbus use of
method void org.freedesktop.Notifications.CloseNotification(uint id) [1]
to specifically target just the desired notifications, is unfortunately not obvious ...
however ...
Another answer
Can org.freedesktop.Notifications.CloseNotification(uint id) be triggered and invoked via DBus?
shows how to use [1]
, at least with notify-send
, but unfortunately not for arbitrary notifying aps. though some aps. have custom interfaces to control pop-up notifications.
cross refs.: