From 6282fdf94ba9b755b66be2d7b56a91423723a3b9 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 2 Oct 2025 12:25:31 +0200 Subject: up --- .local/bin/fetch_mail | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to '.local') 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; } -- cgit v1.2.3