Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a way to enable extglob in dunstrc file #645

Closed
Rodrigo-Barros opened this issue Aug 7, 2019 · 14 comments · Fixed by #1017
Closed

There is a way to enable extglob in dunstrc file #645

Rodrigo-Barros opened this issue Aug 7, 2019 · 14 comments · Fixed by #1017

Comments

@Rodrigo-Barros
Copy link

Hi, this is not a bug, just a question to know if is there a way to enable extglob in dunstrc file, I really would to know how enable, I put an spefic sound for all notifications, but some apps have your own notification sound, and when is a notification is fired for these apps play two songs at same time.

I trying to make of following way:

[playsound]
    icon = "dialog-information"
    desktop_entry = "!(org.gnome.clocks)"
    script = /home/rodrigo/.local/bin/notification-sound # custom script path

and do not works.

or who knows made a blacklist for spefic apps, I know this could be hard, so would be nice if extglob works :)

@bebehei
Copy link
Member

bebehei commented Aug 8, 2019

Firstly, we process the values of the rules via fnmatch. man fnmatch(3am):

The fnmatch extension provides an AWK interface to the fnmatch(3) routine.

I'm not that familiar with AWK, but maybe you are able to do it. If successful, please report!


As a workaround, you could filter inside the script. Watch the parameters:

  • ${1}: The appname
  • ${2}: the summary
  • ${3}: the full body
  • ${4}: the icon
  • ${5}: the urgency level

With special foo, you could work around this. However there is no desktop_entry yet available as a script parameter.

@Rodrigo-Barros
Copy link
Author

@bebehei I am not familiar with AWK too, then I choose the second one, and the result was Great (at least untill now :) the most difficulty was choose which parameters to use for stop play the sound, And I almost forget thanks these tips help me a lot.

If anyone want make a similar feel free to modify my humbly script

#!/usr/bin/python
from os import system
from sys import argv
blacklist = ["Tempo esgotado!", "Thunderbird"]
play_sound = 1
system("echo %s" % argv[2] ) # this line is for debug proposes only, comment if necessary
try:
    if [ argv[2] != "" ]:
        summary = argv[2]
except:
    summary = ""

if  summary != "" :
    for i in blacklist:
        if summary == i:
            play_sound = 0

if play_sound == 1:
    system("cvlc --play-and-exit /home/rodrigo/Music/xbox-notification-sound-2018.mp3")

@bebehei
Copy link
Member

bebehei commented Aug 9, 2019

Which dunst version do you use? 1.4.x or 1.3.x? Master?

@Rodrigo-Barros
Copy link
Author

I'm using version 1.4.1 (2019-07-03).

@bebehei
Copy link
Member

bebehei commented Aug 10, 2019

Shit. After reading the manpage more carefully, I see the problem. !(pattern) is a GNU extension and we disabled gnu extensions in #407.

@bebehei
Copy link
Member

bebehei commented Aug 12, 2019

@tsipinakis shall we enable the _GNU_SOURCE again while loading fnmatch.h? I assume non-GNU systems, this won't change anything, but for GNU systems, we enable negative matching. (IMHO an important feature to have matching patterns).

@tsipinakis
Copy link
Member

I'm fine with that though it'll be a challenge on how to document that, a config file would work on one system but break on another depending on libc extension support - not exactly easy to debug from a user perspective.

@tsipinakis
Copy link
Member

As mentioned in #658, this works for scripts but not for any other attributes like overriding the icon. Given the usefulness I now think it's worth the trouble to enable GNU extensions just for fnmatch.

I'll look into it tomorrow.

tsipinakis added a commit to tsipinakis/dunst that referenced this issue Aug 31, 2019
@dylantjb
Copy link

dylantjb commented Feb 6, 2021

system("cvlc --play-and-exit /home/rodrigo/Music/xbox-notification-sound-2018.mp3")

Argv[2] did not work for me but argv[1] did.

notifications.py

#!/usr/bin/python
from os import system
from sys import argv

blacklist = ["discord"]

if argv[1] not in blacklist:
    system("paplay ~/path/to/alert.wav")

dunstrc

[play_sound]
    summary = "*"
    script = ~/path/to/notifications.py

@Rodrigo-Barros
Copy link
Author

system("cvlc --play-and-exit /home/rodrigo/Music/xbox-notification-sound-2018.mp3")

Argv[2] did not work for me but argv[1] did.

notifications.py

#!/usr/bin/python
from os import system
from sys import argv

blacklist = ["discord"]

if argv[1] not in blacklist:
    system("paplay ~/path/to/alert.wav")

dunstrc

[play_sound]
    summary = "*"
    script = ~/path/to/notifications.py

Hey thank you @dylantjb You improve the readable of my script a lot, you can add these lines:
system("echo %s" % argv[2] )
in notifications.py to debug and see if the appname or summary matches with you want.

@fwsmit
Copy link
Member

fwsmit commented Jun 7, 2021

It is recommended to use environment variables instead of the arguments passed to the scripts as they may be deprecated soon. (comments in #811).

@dylantjb
Copy link

dylantjb commented Jun 7, 2021

In that case I'll provide an updated script for reference.

notifications.sh

#!/usr/bin/env bash

blacklist=( "discord" "your app here" )

[[ ! " ${blacklist[@]} " =~ " $DUNST_APP_NAME " ]] && aplay "/path/to/sound"

dunstrc

[play_sound]
    summary = "*"
    script = "/path/to/notifications.sh"

Should something like this be added to the wiki?

@fwsmit
Copy link
Member

fwsmit commented Jun 7, 2021

Should something like this be added to the wiki?

Yeah that would be great!

fwsmit added a commit to fwsmit/dunst that referenced this issue Jan 15, 2022
This enables more advanced regular expression syntax. It can be enabled
with `enable_posix_regex`.

Fixes: dunst-project#1013
Fixes: dunst-project#645
Fixes: dunst-project#658
fwsmit added a commit to fwsmit/dunst that referenced this issue Jan 15, 2022
This enables more advanced regular expression syntax. It can be enabled
with `enable_posix_regex`.

Fixes: dunst-project#1013
Fixes: dunst-project#645
Fixes: dunst-project#658
fwsmit added a commit to fwsmit/dunst that referenced this issue Jan 16, 2022
This enables more advanced regular expression syntax. It can be enabled
with `enable_posix_regex`.

Fixes: dunst-project#1013
Fixes: dunst-project#645
Fixes: dunst-project#658
@fwsmit
Copy link
Member

fwsmit commented Jan 16, 2022

Regex is implemented in #1017. It should be better than extglob.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants