diff options
| -rw-r--r-- | activity_bar.pl | 31 | 
1 files changed, 26 insertions, 5 deletions
| diff --git a/activity_bar.pl b/activity_bar.pl index c612092..e76486b 100644 --- a/activity_bar.pl +++ b/activity_bar.pl @@ -1,33 +1,54 @@  use strict;  use warnings; +use IO::Socket::INET; +  weechat::register(  	'activity_bar',  	'Teddy Wing',  	'1.0',  	'GPL-3.0-or-later',  	'Monitor activity in all buffers and update AnyBar', -	'', +	'shutdown',  	''  ); +# Flush socket immediately. +$| = 1; + +my $socket = IO::Socket::INET->new( +	PeerAddr => 'localhost', +	PeerPort => '1738', +	Proto => 'udp', +) or die "error: can't create socket: $!"; + +sub shutdown { +	$socket->close(); +} + +  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"); +		anybar_send('blue');  	}  	elsif ($highlight == 1) { -		weechat::print('', "Highlight in $buffer_name: $message"); +		anybar_send('purple');  	}  	else { -		weechat::print('', "Message in $buffer_name: $message"); +		anybar_send('orange');  	}  	return weechat::WEECHAT_RC_OK;  } + +sub anybar_send { +	my ($message) = @_; + +	$socket->send($message); +} | 
