diff options
Diffstat (limited to 'demo/xcowsaylogmon.pl')
-rwxr-xr-x | demo/xcowsaylogmon.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/demo/xcowsaylogmon.pl b/demo/xcowsaylogmon.pl new file mode 100755 index 0000000..c4d5ab5 --- /dev/null +++ b/demo/xcowsaylogmon.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +my $dispnum = "0"; +$dispnum = $1 if $ENV{'DISPLAY'} =~ /(\d+)/; + +my $logfile = "/var/log/Xorg.$dispnum.log"; +my $program = '/usr/bin/fold -s -w 60 | /usr/bin/xcowsay -t 1'; +#my $program = '/bin/cat'; +my $sleeptime = 1; + +my %msghash; +my $hash; + +open(FH, '<', $logfile) or die "Failed to open log file for reading: $!\n"; + +for (;;) { + while(<FH>) { + next unless /avc:\s+/; + ($hash = $_) =~ s/ for .*?scontext=//; + $hash =~ s/^\[.*?\]//; + next if exists($msghash{$hash}); + + open(PH, '|-', $program) or die "Failed to open pipe: $!\n"; + print PH $_; + close(PH); + + $msghash{$hash} = 1; + } + sleep($sleeptime); + seek(FH, 0, 1); +# %msghash = (); +} +close(FH); |