From a5af07262cdd45bdf5461cef069fd12eb7b22ce6 Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Thu, 31 Jul 2025 14:43:06 -0400 Subject: update mail workflow --- bin/.local/bin/scripts/checkmail | 33 +++++++++++++++++++++++++++++---- bin/.local/bin/scripts/cleanmail | 4 ++++ bin/.local/bin/scripts/perl/checkmail | 13 ------------- 3 files changed, 33 insertions(+), 17 deletions(-) delete mode 100755 bin/.local/bin/scripts/perl/checkmail (limited to 'bin/.local') 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:lists@t2sde.org notmuch tag +emacs-devel +emacs +contrib -- to:emacs-devel@gnu.org notmuch tag +emacs-humanities +emacs -- to:emacs-humanities@gnu.org notmuch tag +emacs-org +emacs +org-mode -- to:emacs-orgmode@gnu.org -# 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, ">>") -} -- cgit v1.2.3