summaryrefslogtreecommitdiffstats
path: root/.local/bin/fetch_mail
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-10-02 12:25:31 +0200
committerjoe <rbo@gmx.us>2025-10-02 12:25:31 +0200
commit6282fdf94ba9b755b66be2d7b56a91423723a3b9 (patch)
treef0367fc04dd9fb60265ee7d7105909b72d6ed9c2 /.local/bin/fetch_mail
parentup (diff)
downloaddotfiles-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 '.local/bin/fetch_mail')
-rwxr-xr-x.local/bin/fetch_mail25
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;
}