diff options
author | joe <rbo@gmx.us> | 2025-10-02 12:25:31 +0200 |
---|---|---|
committer | joe <rbo@gmx.us> | 2025-10-02 12:25:31 +0200 |
commit | 6282fdf94ba9b755b66be2d7b56a91423723a3b9 (patch) | |
tree | f0367fc04dd9fb60265ee7d7105909b72d6ed9c2 /.local/bin | |
parent | up (diff) | |
download | dotfiles-bsd-6282fdf94ba9b755b66be2d7b56a91423723a3b9.tar.gz dotfiles-bsd-6282fdf94ba9b755b66be2d7b56a91423723a3b9.tar.bz2 dotfiles-bsd-6282fdf94ba9b755b66be2d7b56a91423723a3b9.tar.xz dotfiles-bsd-6282fdf94ba9b755b66be2d7b56a91423723a3b9.tar.zst dotfiles-bsd-6282fdf94ba9b755b66be2d7b56a91423723a3b9.zip |
up
Diffstat (limited to '')
-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; } |