projects
/
clearscm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git+ssh://github.com/adefaria/clearscm
[clearscm.git]
/
bin
/
announceEmail.pl
diff --git
a/bin/announceEmail.pl
b/bin/announceEmail.pl
index
d21003b
..
cf3dc49
100755
(executable)
--- a/
bin/announceEmail.pl
+++ b/
bin/announceEmail.pl
@@
-40,7
+40,7
@@
$Date: 2019/04/04 13:40:10 $
Where:
-usa|ge Print this usage
-h|elp Detailed help
Where:
-usa|ge Print this usage
-h|elp Detailed help
- -v|erbose Verbose mode (Default:
-
verbose)
+ -v|erbose Verbose mode (Default:
Not
verbose)
-de|bug Turn on debugging (Default: Off)
-user|name User name to log in with (Default: $USER)
-de|bug Turn on debugging (Default: Off)
-user|name User name to log in with (Default: $USER)
@@
-105,6
+105,9
@@
my @greetings = (
"What's this? A new message",
);
"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)},
my %opts = (
usage => sub { pod2usage },
help => sub { pod2usage(-verbose => 2)},
@@
-116,26
+119,31
@@
my %opts = (
imap => $defaultIMAPServer,
);
imap => $defaultIMAPServer,
);
+sub notify($) {
+ my ($msg) = @_;
+
+ my $cmd = "notify-send -i $icon -t $timeout '$msg'";
+
+ Execute $cmd;
+
+ return;
+} # notify
+
sub interrupted {
if (get_debug) {
sub interrupted {
if (get_debug) {
-
$log->msg("Turning off debugging")
;
+
notify 'Turning off debugging'
;
set_debug 0;
} else {
set_debug 0;
} else {
-
$log->msg("Turning on debugging"
);
+
notify ('Turning on debugging'
);
set_debug 1;
} # if
return;
} # interrupted
set_debug 1;
} # if
return;
} # interrupted
-sub Connect2IMAP;
-
-sub restart {
- $log->dbug("Re-establishing connection to $opts{imap} as $opts{username}");
- Connect2IMAP;
+sub restart;
- goto MONITORMAIL;
-} # restart
+sub Connect2IMAP;
$SIG{USR1} = \&interrupted;
$SIG{USR2} = \&restart;
$SIG{USR1} = \&interrupted;
$SIG{USR2} = \&restart;
@@
-221,6
+229,10
@@
sub MonitorMail() {
# Google Talk doesn't like #
$subject =~ s/\#//g;
# 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";
# Now speak it!
my $logmsg = "From $from $subject";
@@
-259,6
+271,16
@@
sub MonitorMail() {
return;
} # MonitorMail
return;
} # MonitorMail
+sub restart {
+ my $msg = "Re-establishing connection to $opts{imap} as $opts{username}";
+
+ $log->dbug($msg);
+
+ Connect2IMAP;
+
+ MonitorMail;
+} # restart
+
END {
# If $log is not yet defined then the exit is not unexpected
if ($log) {
END {
# If $log is not yet defined then the exit is not unexpected
if ($log) {