weechat-notify-send
weechat-notify-send copied to clipboard
Show notifications only when WeeChat is unfocused
Hello,
It would be nice to have a way to only show notifications when weechat is not focused. When already looking at weechat, there is no need for a notification.
This could done using the command
xdotool getactivewindow getwindowname
I have tested it with the newest version of weechat, termite terminal emulator on i3 window manager. There could be some option to hide top not show the when window tiitle includes "weechat" e.g.
This could also be connected to https://github.com/s3rvac/weechat-notify-send/issues/6
Let me know what you think.
Hi,
thanks for your feature request. This is an often-desired functionality that is currently missing in the plugin.
As outlined in #6, the principal problem lies in a portable detection whether WeeChat has focus or not. The WeeChat's API unfortunately does not provide any way of detecting this.
I know about xdotool
as I use it in many of my scripts. However, I am afraid it is not suitable for reliably detecting WeeChat's focus. First of all, when I run WeeChat in Konsole, xdotool
always reports just nbs3rvac — Konsole
. When I run WeeChat in Yakuake, xdotool
always reports just Yakuake
. Even if it reported correct results for these terminals, there would be other problems, like detecting WeeChat's focus when run inside TMux. And this is just the tip of the iceberg because there is a lot of different terminal emulators... :(
The second, less severe reason for not using xdotool
might be that many Linux distributions do not install xdotool
by default. This would require users of the plugin to install it manually.
In conclusion, it all boils down to portable and reliable detection of WeeChat's focus.
Hi @s3rvac thanks for your feedback. Well I understand that the proposed method of detecting wouldn't work for every terminal and configuration, but since it's an optional setting It could be useful for the people with compatible terminals and not harm others.
The string or regex that is compared to the window title to check whether the notification is shown or not could be user-configurable. This would be the only needed setting actually and could default to a regex that doesn't match anything.
Default setting:
suppress_notifications_on_title = \b\B
So if I leave it with the default, notifications are always shown.
Custom setting:
suppress_notifications_on_title = /Weechat/
Notifications are not shown if "Weechat" is contained in the windows title.
I will think about it. I would rather have a solution that would work for most setups, but I guess that would be hard to achieve.
No need for xdotool
, see here for a more standard way: https://github.com/s3rvac/weechat-notify-send/issues/6#issuecomment-356768153
The easier would be to set a new configuration for the script to change the binary to execute (currently notify-send
) so people could just implement functionalities like this in a custom script.