diff options
Diffstat (limited to '')
-rw-r--r-- | .config/isyncrc | 5 | ||||
-rw-r--r-- | .config/mutt/defaults.muttrc | 2 | ||||
-rw-r--r-- | .config/mutt/sig/1-gmx_rbo | 2 | ||||
-rw-r--r-- | .config/mutt/sig/2-gmx_shop | 2 | ||||
-rwxr-xr-x | .local/bin/fetch_mail | 84 |
5 files changed, 54 insertions, 41 deletions
diff --git a/.config/isyncrc b/.config/isyncrc index cf51179..abd861f 100644 --- a/.config/isyncrc +++ b/.config/isyncrc @@ -7,7 +7,6 @@ User rbo@gmx.us PassCmd "pass show mutt/gmx_rbo" AuthMechs LOGIN TLSType IMAPS -CertificateFile /etc/ssl/certs/ca-certificates.crt MaildirStore gmx_rbo-local SubFolders Verbatim @@ -32,7 +31,6 @@ User rbo_shop@gmx.us PassCmd "pass show mutt/gmx_shop" AuthMechs LOGIN TLSType IMAPS -CertificateFile /etc/ssl/certs/ca-certificates.crt MaildirStore gmx_shop-local SubFolders Verbatim @@ -57,7 +55,6 @@ User bousset.rudy@gmail.com PassCmd "pass show mutt/gmail_br" AuthMechs LOGIN TLSType IMAPS -CertificateFile /etc/ssl/certs/ca-certificates.crt MaildirStore gmail_br-local SubFolders Verbatim @@ -82,7 +79,6 @@ User olsen.oyvind.nor@gmail.com PassCmd "pass show mutt/gmail_oon" AuthMechs LOGIN TLSType IMAPS -CertificateFile /etc/ssl/certs/ca-certificates.crt MaildirStore gmail_oon-local SubFolders Verbatim @@ -107,7 +103,6 @@ ExpireUnread no ## PassCmd "pass show mutt/gmail_tos" ## AuthMechs LOGIN ## SSLType IMAPS -## CertificateFile /etc/ssl/cert.pem ## ## MaildirStore gmail_tos-local ## SubFolders Verbatim diff --git a/.config/mutt/defaults.muttrc b/.config/mutt/defaults.muttrc index e4c6166..e56f6d4 100644 --- a/.config/mutt/defaults.muttrc +++ b/.config/mutt/defaults.muttrc @@ -108,7 +108,7 @@ bind editor <Tab> complete-query macro index,pager a "<enter-command>set my_pipe_decode=\$pipe_decode pipe_decode<return><pipe-message>abook -C $XDG_CONFIG_HOME/abook/abookrc --datafile $XDG_DATA_HOME/abook/addressbook --add-email<return><enter-command>set pipe_decode=\$my_pipe_decode; unset my_pipe_decode<return>" "add the sender address to abook" macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read" -macro index O "<shell-escape>fetch_mail.sh<enter>" "run mbsync to sync all mail" +macro index O "<shell-escape>fetch_mail<enter>" "run mbsync to sync all mail" macro index \Cf "<enter-command>unset wait_key<enter><shell-escape>printf 'Enter a search term to find with notmuch: '; read x; echo \$x >$XDG_CACHE_HOME/mutt_terms<enter><limit>~i \"\`notmuch search --output=messages \$(cat $XDG_CACHE_HOME/mutt_terms) | head -n 600 | perl -le '@a=<>;s/\^id:// for@a;$,=\"|\";print@a' | perl -le '@a=<>; chomp@a; s/\\+/\\\\+/ for@a;print@a' \`\"<enter>" "show only messages matching a notmuch pattern" macro index A "<limit>all\n" "show all messages (undo limit)" macro compose Y "<first-entry>\ diff --git a/.config/mutt/sig/1-gmx_rbo b/.config/mutt/sig/1-gmx_rbo index 222e28b..4df7164 100644 --- a/.config/mutt/sig/1-gmx_rbo +++ b/.config/mutt/sig/1-gmx_rbo @@ -1,3 +1,3 @@ joe -https://jozan.org +https://jozan.org/ +337 86 27 02 09 diff --git a/.config/mutt/sig/2-gmx_shop b/.config/mutt/sig/2-gmx_shop index 222e28b..4df7164 100644 --- a/.config/mutt/sig/2-gmx_shop +++ b/.config/mutt/sig/2-gmx_shop @@ -1,3 +1,3 @@ joe -https://jozan.org +https://jozan.org/ +337 86 27 02 09 diff --git a/.local/bin/fetch_mail b/.local/bin/fetch_mail index b466432..743d027 100755 --- a/.local/bin/fetch_mail +++ b/.local/bin/fetch_mail @@ -2,12 +2,22 @@ use strict; use warnings; -use threads; use Fcntl; use Env qw(HOME); use constant MC_FILE_PATH => '/tmp/mc_'; +sub test_gpg +{ + my $ret; + + $ret = system("echo test | gpg2 --sign --batch --no-tty --pinentry-mode error -o /dev/null >/dev/null 2>&1"); + if ($ret != 0) { + notify(" gpg locked | can't fetch mails"); + } + return $ret; +} + sub notify { my ($str) = @_; @@ -27,7 +37,7 @@ sub get_new_mail system('killall mbsync >/dev/null 2>&1'); $ret = system('mbsync', $acc); - if ($ret != 0) { + if ($ret != 0) { notify(" $acc: failed to sync mails"); } return; @@ -61,31 +71,29 @@ sub fetch_thread { my ($acc) = @_; - # my $pre_count = -1; - # my $mc_file = MC_FILE_PATH . $acc; - # my $fh; - # if (-f $mc_file) { - # open($fh, '+<', $mc_file) or die $!; - # $pre_count = <$fh>; - # } else { - # open($fh, '+>', $mc_file) or die $!; - # $pre_count = -1; - # } - # # if ($pre_count == -1) { - # # $pre_count = count_new_mails($_, $maildir); - # # } - # get_new_mail($acc); - # my $post_count = count_new_mails($acc); - # if ($post_count > $pre_count && $post_count > 0) { - # my $notify_str = ' ' . $acc . ': ' . $post_count . ' new mail'; - # $notify_str .= ($post_count > 1 ? "s\n" : "\n"); - # notify($notify_str) - # } - # seek($fh, 0, 0); - # print $fh "$post_count"; - # close($fh); - print "hey $acc\n"; - threads->detach(); + my $pre_count = -1; + my $mc_file = MC_FILE_PATH . $acc; + my $fh; + if (-f $mc_file) { + open($fh, '+<', $mc_file) or die $!; + $pre_count = <$fh>; + } else { + open($fh, '+>', $mc_file) or die $!; + $pre_count = -1; + } + # if ($pre_count == -1) { + # $pre_count = count_new_mails($_, $maildir); + # } + get_new_mail($acc); + my $post_count = count_new_mails($acc); + if ($post_count > $pre_count && $post_count > 0) { + my $notify_str = ' ' . $acc . ': ' . $post_count . ' new mail'; + $notify_str .= ($post_count > 1 ? "s\n" : "\n"); + notify($notify_str) + } + seek($fh, 0, 0); + print $fh "$post_count"; + close($fh); return; } @@ -94,14 +102,24 @@ sub fetch_mail $ENV{'MAIL'} = $HOME . '/.local/share/mail'; $ENV{'GNUPGHOME'} = $HOME . '/.local/share/gnupg'; $ENV{'PASSWORD_STORE_DIR'} = $HOME . '/.local/share/pass'; - my @threads; + my @pids; + my $ret; - # test gpg + $ret = test_gpg(); + if ($ret != 0) { + return; + } my @accs = get_all_accounts(); - push(@threads, threads->new(\&fetch_thread, $_)) for (@accs); - # $_->join() for (@threads); - print "done\n"; - # notify($notify_str) if (length($notify_str) > $og_length); + for (@accs) { + my $pid = fork(); + if (not $pid) { + fetch_thread($_); + return; + } + push(@pids, $pid); + + } + while (wait() != -1) {} return; } |