A New Notification Plugin For WeeChat

In this post, I would like to present weechat-notify-send, a new WeeChat plugin that I wrote. It sends highlight and private-message notifications through notify-send.

What Is WeeChat?

WeeChat is an open-source, multi-platform, fast, light, and extensible chat client that I use. It mainly supports IRC, but with BitlBee, you can use it to communicate through a variety of different protocols, like IRC, XMPP/Jabber (including Google Talk), and Twitter. This is very nice because it allows you to use a single client for many communication protocols.

The main reason why I use use WeeChat+BitleBee is that it runs in a terminal (thus not interrupting my terminal-based workflow), is highly customizable and extensible with plugins, uses text files for its configuration, supports many communication protocols, and has various built-in features, like smart filtering.

Why Another Notification Plugin?

If you take a look at available notification plugins, you will see a great variety of already existing plugins. Thus, you may wonder: why another notification plugin?

I have tried many of them, but either they were not working properly or did not provide all the features I would like. So, I have decided to write my own plugin: weechat-notify-send.

Introducing weechat-notify-send

The Screenshot plugin sends highlight and private-message notifications through notify-send. A sample screenshot can be seen on the right side of this text. Note, however, that the precise appearance depends on the configuration of your notification system as well as on the used icon.

The plugin is written in Python, and works with Python 2 as well as Python 3. It is tested using the standard unittest and unittest.mock modules. I have tried to keep the code clean so it is easy to understand and extend.

The plugin is released under the MIT open-source license.

Installation

Simply put the notify_send.py script to ~/.weechat/python/, and add a symbolic link to it in the ~/.weechat/python/autoload/ directory to make the script load automatically when WeeChat starts:

$ cd ~/.weechat/python
$ wget https://raw.githubusercontent.com/s3rvac/weechat-notify-send/master/notify_send.py
$ cd ~/.weechat/python/autoload
$ ln -s ../notify_send.py

Options

The plugin allows you to set the following options, either by running /set plugins.var.python.notify_send.XXX YYY or by using the iset.pl plugin.

  • notify_on_highlights: Send notifications on highlights. Default: on.
  • notify_on_privmsgs: Send notifications on private messages. Default: on.
  • notify_on_filtered_messages: Send notifications also on filtered (hidden) messages. Default: off.
  • notify_when_away: Send also notifications when away. Default: on.
  • notify_for_current_buffer: Send also notifications for the currently active buffer. Default: on.
  • notify_on_all_messages_in_buffers: A comma-separated list of buffers for which you want to receive notifications on all messages that appear in them. Default: ''.
  • min_notification_delay: A minimal delay in milliseconds between successive notifications from the same buffer. It is used to protect from floods/spam. Set it to 0 to disable this feature (i.e. all notifications will be shown). Default: 500 milliseconds.
  • ignore_buffers: A comma-separated list of buffers from which no notifications should be shown. Default: ''.
  • ignore_buffers_starting_with: A comma-separated list of buffer prefixes from which no notifications should be shown. Default: ''.
  • ignore_nicks: A comma-separated list of nicks from which no notifications should be shown. Default: ''.
  • ignore_nicks_starting_with: A comma-separated list of nick prefixes from which no notifications should be shown. Default: ''.
  • nick_separator: A separator to be put between a nick and a message. Default: : .
  • escape_html: Escapes the <, >, and & HTML characters in notification messages. Default: on.
  • max_length: The maximal length of a notification (0 means no limit). Default: 72.
  • ellipsis: An ellipsis to be used for notifications that are too long. Default: [..].
  • icon: A path to an icon to be shown in notifications. Default: /usr/share/icons/hicolor/32x32/apps/weechat.png.
  • timeout: Time after which the notification disappears (in milliseconds). Set it to 0 to disable the timeout. Default: 5000 (5 seconds).
  • transient: When a notification expires or is dismissed, remove it from the notification bar. Set it to off to keep the notification. Default: on.
  • urgency: Notification urgency (low, normal, critical). Default: normal.

Feedback

If you have a suggestion or a bug report, I will be very glad to get your feedback, either as a pull request, issue, or even just a simple Thanks.

Leave a Comment.