diff options
| -rwxr-xr-x | bin/.local/bin/scripts/checkmail | 33 | ||||
| -rwxr-xr-x | bin/.local/bin/scripts/cleanmail | 4 | ||||
| -rwxr-xr-x | bin/.local/bin/scripts/perl/checkmail | 13 |
3 files changed, 33 insertions, 17 deletions
diff --git a/bin/.local/bin/scripts/checkmail b/bin/.local/bin/scripts/checkmail index 2596b71..dbe0384 100755 --- a/bin/.local/bin/scripts/checkmail +++ b/bin/.local/bin/scripts/checkmail @@ -1,13 +1,38 @@ #!/bin/bash +ICON="/home/bard/dotfiles-stow/fvwm/.fvwm/icon/Yoritsuki/Kinchaku (drawstring bag).png" +LOG_FILE="$HOME/.cache/checkmail" + +notify-send --icon "$ICON" "Mail sync in progress" + +countbefore=$(notmuch count) +deleted=$(notmuch count tag:del) + +# Move "deleted" messages to Gmail Trash folder before syncing +notmuch search --output=files --format=text0 tag:del | \ + xargs -0 --no-run-if-empty -I{} mv {} ~/Mail/gmail-devel/trash/cur/ + mbsync -a notmuch new -notmuch search --format=text0 --output=files tag:del | xargs -0 --no-run-if-empty rm + +# Tagging notmuch tag +linux +contrib -- to:[email protected] notmuch tag +emacs-devel +emacs +contrib -- to:[email protected] notmuch tag +emacs-humanities +emacs -- to:[email protected] notmuch tag +emacs-org +emacs +org-mode -- to:[email protected] -# logging -LOG_FILE="$HOME/.cache/checkmail" -echo "Last mail sync at $(date)" >> $LOG_FILE +countafter=$(notmuch count) +added=$((countafter - countbefore)) + +if [ "$added" -lt 0 ]; then + added=0 +fi + +# Logging +echo "Last mail sync at $(date)" >> "$LOG_FILE" + +if [ "$added" -gt 0 ] || [ "$deleted" -gt 0 ]; then + notify-send --icon "$ICON" "Mail Sync Summary" "Added: $added\nDeleted: $deleted\nTotal: $countafter" +else + notify-send --icon "$ICON" "Mail Sync Summary" "Nothing has changed" +fi diff --git a/bin/.local/bin/scripts/cleanmail b/bin/.local/bin/scripts/cleanmail index 9a21e10..1f72d67 100755 --- a/bin/.local/bin/scripts/cleanmail +++ b/bin/.local/bin/scripts/cleanmail @@ -1,4 +1,8 @@ #!/bin/bash +countbefore=$(notmuch count tag:del) notmuch search --format=text0 --output=files tag:del | xargs -0 --no-run-if-empty rm notmuch new +countafter=$(notmuch count tag:del) + +notify-send "$countafter messages deleted" diff --git a/bin/.local/bin/scripts/perl/checkmail b/bin/.local/bin/scripts/perl/checkmail deleted file mode 100755 index 4530334..0000000 --- a/bin/.local/bin/scripts/perl/checkmail +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -my $log_file="$HOME/.cache/checkmail" - -sub update_mail { - system("mbsync -a"); - system("notmuch new"); - # read log file in append mode '>>' and log date synced - open(log_file, ">>") -} |
