Xfce Forum

Sub domains
 

You are not logged in.

#1 2018-10-15 00:20:00

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Is there a way to filter notifications?

Is there a way to filter out some desktop notifications.

If I have two or more notifications from two different applications.

notify-send "Title 1" 'Message...' -i dialog-information     -t 0 -h int:transient:1 
notify-send "Title 2" 'Message...' -i dialog-information     -t 0 -h int:transient:1
notify-send "Battery low" 'Message...' -i dialog-information     -t 0 -h int:transient:1

The best I can do is to write a python script to listen to notifications and as soon as it opens
close the notification I don't want. I 'm curious if there is another way.

python-dbus, wmctrl required
This would run like a daemon and when the summary matches, the last notification will be closed.

#!/usr/bin/env python
import glib
import dbus
import os
import time
from dbus.mainloop.glib import DBusGMainLoop

def close_notification(bus, message):
  keys = ["app_name", "replaces_id", "app_icon", "summary",
          "body", "actions", "hints", "expire_timeout"]
  args = message.get_args_list()
  print bus
  if len(args) == 8:
    notification = dict([(keys[i], args[i]) for i in range(8)])
    print notification
    if notification["summary"] == "Battery low":
       time.sleep(.5)
       os.system("wmctrl -i -c $(wmctrl -lx | awk '/xfce4-notifyd\.Xfce4-notifyd/{print $1}' | tail -n 1)")

loop = DBusGMainLoop(set_as_default=True)
session_bus = dbus.SessionBus()
session_bus.add_match_string_non_blocking("type='method_call',interface='org.freedesktop.Notifications',member='Notify',eavesdrop=true")
session_bus.add_message_filter(close_notification)
glib.MainLoop().run()

In esence  this line closes the llast notification window
wmctrl -i -c $(wmctrl -lx | awk '/xfce4-notifyd\.Xfce4-notifyd/{print $1}' | tail -n 1)
but the position of the next notification messes up.

With xdotool all notifications are closed.
xdotool windowkill $(wmctrl -lx | awk '/xfce4-notifyd\.Xfce4-notifyd/{print $1}' | tail -n 1)

I can see that the newer version of xdotool has windowclose switch, but I think that would have the same effect as wmctrl -c.

Last edited by Misko_2083 (2018-10-15 00:23:24)


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

#2 2018-10-15 06:00:23

ozjd
Member
From: Hawkesbury NSW Australia
Registered: 2012-02-05
Posts: 560
Website

Re: Is there a way to filter notifications?

Go to Settings - Notifications - Applications tab and there you can turn off notifications for each application.

Offline

#3 2018-10-15 07:40:56

Misko_2083
Member
Registered: 2015-10-13
Posts: 191
Website

Re: Is there a way to filter notifications?

ozjd wrote:

Go to Settings - Notifications - Applications tab and there you can turn off notifications for each application.

g5niRv3t.png

I have an older version.

xfce4-notifyd-config --version
xfce4-notifyd-config 0.2.4

I'm attached to this distro because it's clean from systemd.
In Devuan, antix, systemd, although inactive, systemd is still there and can be installed.

I guess I'll have to wait until the strech based is out. That will take some time.


Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c

Offline

Board footer

Powered by FluxBB