dunst-project / dunst

Lightweight and customizable notification daemon
https://dunst-project.org
Other
4.44k stars 338 forks source link

feature: append *desktop-entry* to *script* invocation #1198

Closed ventosus closed 10 months ago

ventosus commented 11 months ago

Issue description

From the default dunstrc:

# Instead of the appname filter, it's recommended to use the desktop_entry filter.
# GLib based applications export their desktop-entry name. In comparison to the appname,                                 
# the desktop-entry won't get localized.
#
# SCRIPTING
# You can specify a script that gets run when the rule matches by
# setting the "script" option.
# The script will be called as follows:
#   script appname summary body icon urgency

It would be really nice to have access to the desktop-entry in scripts. Because that is what is needed to take any actions on the window, the notifiaction has come from:

Take the following as example: I like to intercept notifications from dino (and many other applications) and instead of showing them, I'd like to set the urgent flag of the window, so the given workspace in waybar is highlighted and I can go there when I have time.

Currently I have to define and lookup the dektop-entry (appid in sway terms) in the script. If the script would be invoked with the desktoip-entry, one could directly use the latter.

dunstrc

[dino-urgent]
    desktop_entry = "im.dino.Dino"
    script = ~/.local/bin/notify-urgent
    skip_display = true

.local/bin/notify-urgent

#!/bin/bash

set -e
set -u

appname="${1:-}"

if [ -z "${appname}" ]; then
    exit 1
fi

declare -A appid=(
    ["Dino"]="im.dino.Dino" 
)

exec swaymsg "[app_id=${appid[${appname}]:-${appname}}]" urgent enable

Installation info

fwsmit commented 10 months ago

The desktop entry is already available for scripts in the environment variable DUNST_DESKTOP_ENTRY. I don't want to add more variables to the script invocation, since it's less flexible and harder to deal with from the script side.

ventosus commented 10 months ago

Ah nice, I've nowhere read about those env vars, that solves my issue, indeed.

fwsmit commented 10 months ago

All environment variables are documented in the manual page: https://dunst-project.org/documentation/