Skip to content
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

Show notifications only when WeeChat is unfocused #7

Open
pinpox opened this issue Jul 6, 2017 · 5 comments
Open

Show notifications only when WeeChat is unfocused #7

pinpox opened this issue Jul 6, 2017 · 5 comments

Comments

@pinpox
Copy link

pinpox commented Jul 6, 2017

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 #6

Let me know what you think.

@s3rvac
Copy link
Owner

s3rvac commented Jul 7, 2017

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.

@s3rvac s3rvac changed the title Show notification only when Weechat is unfocused Show notifications only when WeeChat is unfocused Jul 7, 2017
@pinpox
Copy link
Author

pinpox commented Jul 10, 2017

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.

@s3rvac
Copy link
Owner

s3rvac commented Jul 10, 2017

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.

@maximbaz
Copy link

No need for xdotool, see here for a more standard way: #6 (comment)

@lecler-i
Copy link

lecler-i commented Aug 6, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants