Open rosshadden opened 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.
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.
Being able to middle click the popup to copy the latest notification to the clipboard would be excellent.
+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.
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=".
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
maybe something like default_action
or default_script
would do
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.