diff options
author | Teddy Wing | 2023-12-09 20:38:14 +0100 |
---|---|---|
committer | Teddy Wing | 2023-12-09 21:13:53 +0100 |
commit | 3b1b1577710cab043bc35c92b3d295eab3ffbfe3 (patch) | |
tree | c11a104d8a8d28ed629b38490e3bfccbe2d62f7c | |
download | weechat-activity-bar-3b1b1577710cab043bc35c92b3d295eab3ffbfe3.tar.bz2 |
activity_bar.pl: Get notified of activity in buffers
Register a `hook_print` to get notified of activity in buffers. This
prints the message to the WeeChat core buffer.
-rw-r--r-- | activity_bar.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/activity_bar.pl b/activity_bar.pl new file mode 100644 index 0000000..c612092 --- /dev/null +++ b/activity_bar.pl @@ -0,0 +1,33 @@ +use strict; +use warnings; + +weechat::register( + 'activity_bar', + 'Teddy Wing', + '1.0', + 'GPL-3.0-or-later', + 'Monitor activity in all buffers and update AnyBar', + '', + '' +); + +weechat::hook_print('', '', '', 0, 'print_cb', ''); + +sub print_cb { + my ($data, $buffer, $date, $tags, $displayed, $highlight, $prefix, $message) = @_; + + my $buffer_type = weechat::buffer_get_string($buffer, 'localvar_type'); + my $buffer_name = weechat::buffer_get_string($buffer, 'short_name'); + + if ($buffer_type eq 'private') { + weechat::print('', "Private message in $buffer_name: $message"); + } + elsif ($highlight == 1) { + weechat::print('', "Highlight in $buffer_name: $message"); + } + else { + weechat::print('', "Message in $buffer_name: $message"); + } + + return weechat::WEECHAT_RC_OK; +} |