#!/usr/bin/env perl
use File::Temp 'tempfile';
my $command = 'arp -a';
my (undef, $tmp) = tempfile;
while (1) {
system "$command > $tmp";
sleep 1;
my @diff = split "\n", 'bash -c "diff -d -U0 $tmp <($command)"';
shift @diff; shift @diff; shift @diff; # remove diff header
my (@join, @left);
while (my $line = shift @diff) {
if ($line =~ s/^-//) {
push @left, $line;
} elsif ($line =~ s/^\+//) {
push @join, $line;
} else {
warn "found junk line in diff: $line\n";
}
}
if (@join or @left) {
system "kdialog --passivepopup 'joined: @join\nleft: @left'"
}
}