dunst icon indicating copy to clipboard operation
dunst copied to clipboard

Feature request: Focus application on click

Open jzbor opened this issue 3 years ago • 10 comments

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?

jzbor avatar Jun 11 '21 09:06 jzbor

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.

fwsmit avatar Jun 11 '21 10:06 fwsmit

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.

jzbor avatar Jun 11 '21 10:06 jzbor

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 and firefox 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 avatar Jun 11 '21 11:06 fwsmit

@fwsmit Is it possible to configure for myself somehow? Say, run a script on click that does what @jzbor is saying

sarmong avatar Dec 08 '22 20:12 sarmong

Yeah, it should be possible

fwsmit avatar Dec 08 '22 21:12 fwsmit

@fwsmit How?

sarmong avatar Dec 08 '22 21:12 sarmong

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

fwsmit avatar Dec 08 '22 21:12 fwsmit

Yeah, it doesn't work

sarmong avatar Dec 08 '22 21:12 sarmong

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

sarmong avatar Dec 08 '22 21:12 sarmong

The two main problems are

  1. Figuring out who sent a notification (the window id)
  2. Telling the wm to focus that

bynect avatar Feb 21 '24 12:02 bynect