-
Notifications
You must be signed in to change notification settings - Fork 351
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
Option to run script when notification closes #753
Comments
What would be the usecase for this? Can you provide a few examples? Additionally, Here are some events I can think of on the top of my head that close a notification, which of these would trigger this script in your opinion?
|
@tsipinakis Is it really ambiguous though? Either the notification exists or it doesn't, and when that change happens, from existing to not, the script is called? So it would run for all the cases you mentioned and pass the reason of 'closure' to the script, pretty much like I said. And it would always only run once for every notification. I only called it "close" because that was the function I hooked to first, the queues_notification_close_id function in queues.c which "closes" the notification with id. |
I've been interested in something similar but haven't really looked into it. However, I think this is the wrong approach. i.e. abusing the close notification action as a 'clicked' event. I think the cleanest solution here would be implementing #669 or something similar. This has the advantage that it would also call the default actions some programs include, for example in an email client it opens up the email the notification was about. This is how I think this would work configuration-wise: [my-action-rule]
summary = "*" # Match all notifications
action_script = +default:Activate:/path/to/script Breaking this down this means:
It's issues like this that make me wish dunst used yaml as a configuration language instead of ini which would make specifying multiple variables like that easier rather than having to implement our own format. |
@tsipinakis What do you mean "abusing the close notification action as a 'clicked' event"? It's not running as or claimed to be a 'clicked' event, it's a 'closed' event, thus called when the notification is closed, just like "signal_notification_closed" in dbus.c is called when the notification is closed to tell the owner of the notification that the notification is closed, it's got nothing to do with clicked? What you are proposing is a step in the right direction, but in practice it would be the same thing as I said- except for it adding the default action and not being as capable by not also being run when the action isn't used. The former would be easily implemented by the user via a custom script either way (and would even be better since you can process the data yourself before doing something with it...) so going through the hassle of creating the feature for dunst and making the config hella confusing with that formatting seems unnecessary? Adding a close_script run by my description from config still sounds the most reasonable to me:
This would be the final feature needed for custom script running as there would be no scenario not encapsulated by this feature or the 'script' option, it's easy to implement and the configuration for it is as simple as it gets. |
This could be used to add any action not just the default, as mentioned in issue #669. For example, add a 'Copy code' action to copy 2FA codes from any notification, or add play/pause/skip etc actions to media player notifications that don't already implement them. However I do agree that the config format I proposed is too complicated so it'll have to be revised somehow if it's implemented.
Since 1.5 we allow multiple actions for mouse events, how would this deal with I guess this could be similar if in |
@tsipinakis That's a bit more than just adding an action if it doesn't exist like in your previous comment though? And again, harder implementation and confusing configuration. It would be nice to just be able to add a bunch of actions like you say if they don't already exist on the notification but that could be done easily and more 'customizably' by the user via script. It would however be nice to, with configuration format you mentioned, also be able to remove (-) default actions. Though I have no use case for that personally. You can differentiate between intent since it's passed to the script? Mine passes the first action (do_action in this case) and then sets the n->close_script_run to true which prevents it from running again for that notification. I guess you could also check settings.always_run_script and run multiple times like it's done for the 'script' option scripts. |
Now with what you've said and that I've thought this through the config would look like this in my mind: [my-action-rule]
summary = "*"
add_action = Copy 2FA code
remove_action = default
action_script = /path/to/script
So in case any action is chosen This, minus the 2 extra rules is basically what you have implemented in |
@tsipinakis When you say action you are still talking the notification action (like Activate) right? I don't ever use the context menu myself so the usefulness of having the action name passed as well escaped me. Would Otherwise I do think being able to remove default actions is a great feature, and being able to add custom extra actions sounds great for context menu users. |
Yes
Ideally, yes, we can have a script that is called for all events and filtering can be done from the script side. I'm also not sure about the name though. Neither |
@tsipinakis Perfect. I'm more in favor of |
The problem with the |
Whoops sorry I totally forgot to update this. The best I came up with was |
What is the status of the current issue? Is it possible to see it in near future? |
There is no PR for this issue yet. I myself won't implement this at least until #803 is done, since that will overhaul the rules code. PR's are welcome though |
The current "script" option is great, but only runs when the notification is created. I propose adding a feature to run a script when the notification is clicked or closed by either:
The latter is not preferred though since it would destroy compatibility with a lot of old scripts.
While I do realize there exists "half workarounds" (#163) like using the dunstify command with the current "script" option to recreate the notification and then evaluate the result I do think a better solution is needed. For example, if the notification is using raw image data for the icon it won't be passed to the script and thus a full recreation won't be possible unless I'm missing something.
The text was updated successfully, but these errors were encountered: