diff options
Diffstat (limited to '.local/bin/fetch_mail')
-rwxr-xr-x | .local/bin/fetch_mail | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/.local/bin/fetch_mail b/.local/bin/fetch_mail index 0a88914..53967ab 100755 --- a/.local/bin/fetch_mail +++ b/.local/bin/fetch_mail @@ -6,12 +6,25 @@ use Env qw(HOME); use constant MC_FILE_PATH => '/tmp/mc_'; +sub get_new_mail +{ + my $pid; + + $pid = fork(); + exec('herbe', ' failed to fork') if ($pid < 0); + if (not $pid) { + exec('killall', 'mbsync'); + } + while (wait() != -1) {} + return; +} + sub get_all_accounts { my @accs; opendir(my $dh, $ENV{'MAIL'}) or die $!; - @accs = readdir($dh); + @accs = grep { !/^\./ } readdir($dh); closedir($dh); return @accs; } @@ -38,10 +51,14 @@ sub fetch_mail my $maildir = $ENV{'MAIL'} . '/'; my @accs = get_all_accounts(); - print @accs; # my $mc_file = MC_FILE_PATH . $accs[0]; - # my $pre_count = count_new_mails($accs[0], $maildir); - # print $pre_count . "\n"; + my $pre_count = count_new_mails($accs[1], $maildir); + print $pre_count . "\n"; + get_new_mail(); + # get new mail + # my $post_count = count_new_mails($accs[0], $maildir); + # push str + # notify return; } |