X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=bin%2FannounceEmail.pl;h=906b22a70382ca448cee075974b238d7c20f2d40;hb=338c4f27d2fd517aa63544459399aef9b28438be;hp=d21003bc64d709a7f39433ff8fe479083817d1a2;hpb=a9a87bbe82dc57fbb837f86139419eaf76095105;p=clearscm.git diff --git a/bin/announceEmail.pl b/bin/announceEmail.pl index d21003b..906b22a 100755 --- a/bin/announceEmail.pl +++ b/bin/announceEmail.pl @@ -105,6 +105,9 @@ my @greetings = ( "What's this? A new message", ); +my $icon = '/home/andrew/.icons/Thunderbird.jpg'; +my $timeout = 5 * 1000; + my %opts = ( usage => sub { pod2usage }, help => sub { pod2usage(-verbose => 2)}, @@ -116,12 +119,22 @@ my %opts = ( imap => $defaultIMAPServer, ); +sub notify($) { + my ($msg) = @_; + + my $cmd = "notify-send -i $icon -t $timeout '$msg'"; + + Execute $cmd; + + return; +} # notify + sub interrupted { if (get_debug) { - $log->msg("Turning off debugging"); + notify 'Turning off debugging'; set_debug 0; } else { - $log->msg("Turning on debugging"); + notify ('Turning on debugging'); set_debug 1; } # if @@ -131,7 +144,10 @@ sub interrupted { sub Connect2IMAP; sub restart { - $log->dbug("Re-establishing connection to $opts{imap} as $opts{username}"); + my $msg = "Re-establishing connection to $opts{imap} as $opts{username}"; + + $log->dbug($msg); + Connect2IMAP; goto MONITORMAIL; @@ -221,6 +237,10 @@ sub MonitorMail() { # Google Talk doesn't like # $subject =~ s/\#//g; + # Remove long strings of numbers like order numbers. They are uninteresting + my $longNumber = 5; + $subject =~ s/\s+\S*\d{$longNumber,}\S*\s*//g; + # Now speak it! my $logmsg = "From $from $subject";