#!/usr/bin/perl
#Send input to all vty
#Sebastian Kricner
#tuxwave.net Juni 2012
#To use:
#Hold CTRL and press the mouse wheel.
#In the options popup select "send to all vty"

sub on_init
{
	my ($self) = @_;
	$self->{enabled} = 0;
	push @{$self->{term}{option_popup_hook}}, sub{("send to all vty" => $self->{enabled}, sub { $self->{enabled} = shift})};
};

sub on_tt_write
{
	my ($self, $octets) = @_;
	if($self->{enabled})
	{
		foreach my $terminal (urxvt::termlist)
		{
			unless($terminal == $self->{term})
			{
				$terminal->tt_write($octets);
			}
		}
	}
}
