summaryrefslogtreecommitdiffstats
path: root/.local/bin/fetch_mail
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.local/bin/fetch_mail46
1 files changed, 46 insertions, 0 deletions
diff --git a/.local/bin/fetch_mail b/.local/bin/fetch_mail
new file mode 100755
index 0000000..0d35cf5
--- /dev/null
+++ b/.local/bin/fetch_mail
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Env qw(HOME);
+
+use constant MC_FILE_PATH => '/tmp/mc_';
+
+sub get_all_accs
+{
+ opendir(my $dh, $ENV{'MAIL'});
+ return;
+}
+
+sub count_new_mails
+{
+ my ($acc, $maildir) = @_;
+ my $count;
+ my $dir;
+ my $path = $maildir . $acc . '/INBOX/new';
+
+ $count = 0;
+ opendir(my $dh, $path) or die $!;
+ $count = grep { -f "$path/$_"} readdir($dh);
+ closedir($dh);
+ return $count;
+}
+
+sub fetch_mail
+{
+ $ENV{'MAIL'} = $HOME . '/.local/share/mail';
+ $ENV{'GNUPGHOME'} = $HOME . '/.local/share/gnupg';
+ $ENV{'PASSWORD_STORE_DIR'} = $HOME . '/.local/share/pass';
+ my $maildir = $ENV{'MAIL'} . '/';
+ # my @accs = (ACCOUNTS);
+
+ get_all_accs();
+ # my $mc_file = MC_FILE_PATH . $accs[0];
+ # my $pre_count = count_new_mails($accs[0], $maildir);
+ # print $pre_count . "\n";
+ return;
+}
+
+fetch_mail();
+
+__END__