dunst
dunst copied to clipboard
Feature request: Focus application on click
Hi,
First of all thanks for the great work! Many other notification daemons like GNOME's are able to focus the corresponding application on left click. This is useful for lots of applications that don't support a 'focus' action out of the box. Would it be possible to add such functionality to the mouse_*_click
option and to the keyboard shortcuts? Would this maybe be possible via _NET_ACTIVE_WINDOW
?
I don't see how we would know what window to focus and how to focus it in a way that works in every environment. I suspect the gnome notification daemon is talking to the gnome wm directly. If you have more details on how to do it, that would help. It preferable has to work on wayland as well. I'm not against this feature at least.
I know it is not really beautiful, but a relatively simple possibility would be just going through the X windows and matching their class/instance values with the application name passed to dunst. Most applications where you would use this (Spotify, Discord, etc.) open only one window anyway). Here is an example on how to list all windows.
An easier approach would be adding a callback script similar to how it is done with dmenu
and firefox
which is then passed the notification details (e.g. appname, summary and content) as parameters.
I know it is not really beautiful, but a relatively simple possibility would be just going through the X windows and matching their class/instance values with the application name passed to dunst. Most applications where you would use this (Spotify, Discord, etc.) open only one window anyway). Here is an example on how to list all windows.
The thing is, we only have an app name to go off of. This probably doesn't exactly match the window name. It also doesn't work on wayland AFAIK.
An easier approach would be adding a callback script similar to how it is done with
dmenu
andfirefox
which is then passed the notification details (e.g. appname, summary and content) as parameters.
This would be a good compromise and could also be used for other things. I believe there's an issue about this
@fwsmit Is it possible to configure for myself somehow? Say, run a script on click that does what @jzbor is saying
Yeah, it should be possible
@fwsmit How?
Oh nvm, I think the script option doesn't work with on mouse click. You could try it though. Otherwise something had to be changed in Dunst
Yeah, it doesn't work
I guess it won't be difficult to just add some script_on_click
to rules and just run it? I have no experience in C, but I might try
The two main problems are
- Figuring out who sent a notification (the window id)
- Telling the wm to focus that