Dunst: Audio and notification history

Created on 7 Aug 2020  路  12Comments  路  Source: dunst-project/dunst

Hi, i need some help:
My alert script serves the notification sound for all my notification,
but i don't want my mpdnotify script to have sound from alert script.
and i also want to mpdnotify script not to be save in history.

  • how can i make dunst ignore history on a specific script?
  • how can i exclude my alert script for triggering audio notification?

my alert script

#!/bin/bash
paplay ~/.local/share/audio/beep.wav

my mpdnotify script

#!/bin/bash
# mpdnotify
while "true"; do
  notify-send "Now playing" "$(mpc current --wait)"
done

i tried adding it on the bottom of my dunstrc but it doesn't work.

[mpdnotify]
   appname = "mpdnotify"
   history_ignore = yes

my full dunstrc

[global]
    monitor = 0
    follow = keyboard
    geometry = "390x5-5+30"
    corner_radius= 0
    indicate_hidden = yes
    shrink = false
    transparency = 10
    notification_height = 0
    separator_height = 2
    padding = 2
    horizontal_padding = 8
    frame_width = 0
    frame_color = "#1d2021"

    # Define a color for the separator.
    # Possible values are:
    #  * auto: dunst tries to find a color fitting to the background;
    #  * foreground: use the same color as the foreground;
    #  * frame: use the same color as the frame;
    #  * anything else will be interpreted as a X color.
    separator_color = auto
    separator_height = 2

    # Sort messages by urgency.
    sort = yes

    idle_threshold = 120
    font = Monospace 10
    line_height = 0
    markup = full

    # The format of the message. possible variables are:
    #   %a  appname
    #   %s  summary
    #   %b  body
    #   %i  iconname (including its path)
    #   %I  iconname (without its path)
    #   %p  progress value if set ([  0%] to [100%]) or nothing
    #   %n  progress value if set without any extra characters
    #   %%  Literal %
    # Markup is allowed
    format = "<b>%s</b>\n%b"

    alignment = center
    show_age_threshold = 60
    word_wrap = yes
    ellipsize = middle
    ignore_newline = no
    stack_duplicates = true
    hide_duplicate_count = true
    show_indicators = yes
    icon_position = left
    max_icon_size = 40
    icon_path = /usr/share/icons/Adwaita/256x256/status/
    sticky_history = yes
    history_length = 20
    dmenu = /usr/bin/dmenu -p dunst:
    browser = /usr/bin/firefox -new-tab

    # Always run rule-defined scripts, even if the notification is suppressed
    always_run_script = true

    title = Dunst
    class = Dunst
    startup_notification = false

    # Manage dunst's desire for talking
    # Can be one of the following values:
    #  crit: critical features. dunst aborts
    #  warn: only non-fatal warnings
    #  mesg: important messages
    #  info: all unimportant stuff
    #  debug: all less than unimportant stuff
    verbosity = mesg

    corner_radius = 0
    force_xinerama = false

[experimental]
    per_monitor_dpi = false

[shortcuts]
    close = ctrl+space
    close_all = ctrl+shift+space
    history = ctrl+grave
    context = ctrl+shift+period

[urgency_low]
    # IMPORTANT: colors have to be defined in quotation marks.
    # Otherwise the "#" and following would be interpreted as a comment.
    background = "#1d2021"
    foreground = "#928374"
    frame_color = "#458588"
    timeout = 5
    # Icon for notifications with low urgency, uncomment to enable
    #icon = /path/to/icon

[urgency_normal]
    background = "#1d2021"
    foreground = "#ebdbb2"
    frame_color = "#458588"
    timeout = 5
    # Icon for notifications with normal urgency, uncomment to enable
    #icon = /path/to/icon

[urgency_critical]
    background = "#cc2421"
    foreground = "#ebdbb2"
    frame_color = "#fabd2f"
    timeout = 0
    # Icon for notifications with critical urgency, uncomment to enable
    #icon = /path/to/icon

[mpdnotify]
   appname = "mpdnotify"
   history_ignore = yes

[play_sound]
    summary = "*"
    script = ~/.local/bin/etc/alert

# vim: ft=cfg
  • Version: 1.5.0
  • Install type: package
  • Distro and version: Arch Linux 5.7.12
question

All 12 comments

how can i make dunst ignore history on a specific script?

Looks like you already have done that with the mpdnotify rule, just forgot to set the appname in the notify-send call :) (-a flag).

how can i exclude my alert script for triggering audio notification?

Sadly it's not possible to add negative matches to the rule system currently. A hack around that would be to do some filtering on the script side: The appname is passed as the second command line parameter to the script.

@tsipinakis thanks man! :) ignore history is working now lol

how can i exclude my alert script for triggering audio notification?

Sadly it's not possible to add negative matches to the rule system currently. A hack around that would be to do some filtering on the script side: The appname is passed as the second command line parameter to the script.

can you give me some sample on how to do this?

Completely untested bash code/pseudocode:

# Skip alert for mpdnotify
if [[ "$1" == "mpdnotify" ]]
then
    exit 0
fi
...
# Skip alert for mpdnotify
if [[ "$1" == "mpdnotify" ]]
then
    exit 0
fi

@tsipinakis where should i add this? inside my mpdnotify script or alert script?

In the alert script, so it skips playing the sound if the notification is from mpdnotify.

i added the script but it doesn't work

#!/bin/bash
paplay ~/.local/share/audio/beep.wav

# Skip alert for mpdnotify
if [[ "$1" == "mpdnotify" ]]
then
       exit 0
fi

also history_ignore = yes and set_stack_tag doesn't work if i have this in my dunstrc:

[play_sound]
  summary = "*"
  script = "alert"

maybe because of summary = "*"
but when i remove that part, the history_ignore and set_stack_tag is working again.

[mpdnotify]
appname = "mpdnotify"
history_ignore = yes
set_stack_tag = "mpdnotify"
timeout = 3

[voldunst]
appname = "voldunst"
history_ignore = yes
set_stack_tag = "voldunst"
timeout = 3

#[play_sound]
#summary = "*"
#script = "alert"

i think that "*" makes the audio in general notification, even if i set in my script to play a specific audio it still plays the audio that's set in my dunstrc.

for now i removed the audio, the only option here i think if i want audio notification is to disable the alert script in my dunstrc and set it per script and add notify-send blah blah then paplay whatever audio i want which i think is tedious lol

@tsipinakis anyways thanks man for the time in helping me :) i think there's nothing i can do here lol

#!/bin/bash
paplay ~/.local/share/audio/beep.wav
# Skip alert for mpdnotify
if [[ "$1" == "mpdnotify" ]]
then
       exit 0
fi

You put that backwards, the if statement should be at the top so the script exits before the sound plays for mpdnotify.

#!/bin/bash

# Skip alert for mpdnotify
if [[ "$1" == "mpdnotify" ]]
then
       exit 0
fi

paplay ~/.local/share/audio/beep.wav

@tsipinakis oh my bad lol, i see that works now, but the problem now is the history_ignore and set_stack_tag is not working. any idea?

Edit set_stack_tag is working now, but history_ignore still doesn't work.

Edit set_stack_tag is working now, but history_ignore still doesn't work.

Well, that's a bug! Reported with #747 and fixed in master.

@hoaxdream Did that resolve all your questions? Can this issue be closed?

@tsipinakis ah yes. sorry i forgot to close the issue.

Was this page helpful?
0 / 5 - 0 ratings