dunst-project / dunst

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

Custom global actions #669

Open rosshadden opened 5 years ago

rosshadden commented 5 years ago

Is there a way to add a custom global action that would be present in all notifications? I would like to add a copy action which would copy the text of the notification to my clipboard. For notifications created by me I would be able to specify a script and add this action, but most notifications on my system are not initiated by me.

tsipinakis commented 5 years ago

Hi, this is not possible as actions are something the client (read: the program that sent the notification) does, the logic isn't being run on dunst, we only send back the action that was chosen.

However it might be a good idea to consider custom "actions" which in reality are scripts which are called in similar way to the script= directive in dunstrc. I'll leave this open for discussion as a feature request.

infokiller commented 4 years ago

I'm looking for the same functionality as well. Use case: I'd like to add a notification action to copy OTP codes from SMS messages. Given the notification text, a simple regex to match consecutive digits will probably work fine for me. So I could add a custom action to process the notification content and copy OTP codes to the clipboard.

sysfsss commented 3 years ago

Being able to middle click the popup to copy the latest notification to the clipboard would be excellent.

AkashKrDutta commented 3 years ago

+1 for this feature. It would be extremely helpful for me, to point out those notifications that I have missed from dunst (timed-out notifications). I could add a left-click/middle-click action to run a script to increase a shared counter variable. This counter can then be subtracted from dunstctl history count output to get count of those notifications missed from timeouts.

MultiCoreNop commented 1 year ago

Another nice way would be an environment variable DUNST_ADD_ACTIONS (maybe a BASH array) that allows adding (command line, action name) pairs. This could then be filled from within a "script=".

yutkat commented 1 year ago

I recently found the workaround to define custom actions and I will share it with you.

First, I call the shell script using script= in the condition that I want to call. https://github.com/yutkat/dotfiles/blob/a6a483ded2912b9bda8ebaf790f59f5484a803c1/.config/dunst/dunstrc#L456-L459

Then, I could override the notification by adding $DUNST_ID to the --replace-id of notify-send. Next, I can switch by action. https://github.com/yutkat/dotfiles/blob/a6a483ded2912b9bda8ebaf790f59f5484a803c1/.config/dunst/scripts/libreoffice.sh#L9

bynect commented 7 months ago

maybe something like default_action or default_script would do