diff options
author | joe <rbo@gmx.us> | 2025-10-03 12:11:09 +0200 |
---|---|---|
committer | joe <rbo@gmx.us> | 2025-10-03 12:11:09 +0200 |
commit | 3ad37793c02e3e8fbb9056144b02c87bdc7964ae (patch) | |
tree | 28aa7a15a76a2aee742ee5d000927b2ff1d3506c | |
parent | up (diff) | |
download | dotfiles-bsd-3ad37793c02e3e8fbb9056144b02c87bdc7964ae.tar.gz dotfiles-bsd-3ad37793c02e3e8fbb9056144b02c87bdc7964ae.tar.bz2 dotfiles-bsd-3ad37793c02e3e8fbb9056144b02c87bdc7964ae.tar.xz dotfiles-bsd-3ad37793c02e3e8fbb9056144b02c87bdc7964ae.tar.zst dotfiles-bsd-3ad37793c02e3e8fbb9056144b02c87bdc7964ae.zip |
up
-rwxr-xr-x | .config/nnn/plugins/joe_clipper | 7 | ||||
-rwxr-xr-x | .local/bin/fetch_mail | 64 |
2 files changed, 35 insertions, 36 deletions
diff --git a/.config/nnn/plugins/joe_clipper b/.config/nnn/plugins/joe_clipper index 54d8095..dc65b52 100755 --- a/.config/nnn/plugins/joe_clipper +++ b/.config/nnn/plugins/joe_clipper @@ -23,12 +23,7 @@ sub clip_img $pid = fork(); if ($pid == 0) { system("magick '$file' png:- | " . XCLIP . "-t image/png"); - exec( - 'notify-send', - '-t', '2000', - 'clipped image', - ' clipped image' - ); + exec('herbe', ' clipped image'); } return; } diff --git a/.local/bin/fetch_mail b/.local/bin/fetch_mail index 0c743ec..b466432 100755 --- a/.local/bin/fetch_mail +++ b/.local/bin/fetch_mail @@ -26,7 +26,7 @@ sub get_new_mail my $ret; system('killall mbsync >/dev/null 2>&1'); - $ret = system('mbsync', 'qwe'); + $ret = system('mbsync', $acc); if ($ret != 0) { notify(" $acc: failed to sync mails"); } @@ -45,10 +45,10 @@ sub get_all_accounts sub count_new_mails { - my ($acc, $maildir) = @_; + my ($acc) = @_; my $count; my $dir; - my $path = $maildir . $acc . '/INBOX/new'; + my $path = $ENV{'MAIL'} . '/' . $acc . '/INBOX/new'; $count = 0; opendir(my $dh, $path) or die $!; @@ -59,6 +59,33 @@ sub count_new_mails 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(); return; } @@ -67,36 +94,13 @@ 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 $notify_str = " new mails\n"; + my @threads; # test gpg my @accs = get_all_accounts(); - foreach (@accs) { - my $pre_count = -1; - my $mc_file = MC_FILE_PATH . $_; - 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($_); # error if fail - my $post_count = count_new_mails($_, $maildir); - if ($post_count > $pre_count && $post_count > 0) { - my $notify_str = ' ' . $_ . ': ' . $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); - } + push(@threads, threads->new(\&fetch_thread, $_)) for (@accs); + # $_->join() for (@threads); + print "done\n"; # notify($notify_str) if (length($notify_str) > $og_length); return; } |