diff options
Diffstat (limited to 'bin/.local')
| -rwxr-xr-x | bin/.local/bin/scripts/checkmail | 43 | ||||
| -rwxr-xr-x | bin/.local/bin/scripts/cleanmail | 7 |
2 files changed, 27 insertions, 23 deletions
diff --git a/bin/.local/bin/scripts/checkmail b/bin/.local/bin/scripts/checkmail index 2b56894..5e0d73d 100755 --- a/bin/.local/bin/scripts/checkmail +++ b/bin/.local/bin/scripts/checkmail @@ -1,38 +1,37 @@ #!/usr/bin/env 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/ +# delete local files tagged with +del +notmuch search --format=text0 --output=files tag:del | xargs -0 --no-run-if-empty rm +# sync and index new mail mbsync -a notmuch new -# 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] +# auto-tag based on folder location +notmuch tag +inbox -- folder:Inbox or folder:gmail-devel/Inbox or folder:gmail-home/Inbox +notmuch tag +sent -- folder:sent or folder:gmail-devel/sent or folder:gmail-home/sent +notmuch tag +trash -- folder:trash or folder:gmail-devel/trash or folder:gmail-home/trash +notmuch tag +drafts -- folder:drafts +notmuch tag +account/devel -- folder:gmail-devel/Inbox or folder:gmail-devel/sent or folder:gmail-devel/trash or folder:gmail-devel/archive +notmuch tag +account/home -- folder:gmail-home/Inbox or folder:gmail-home/sent or folder:gmail-home/trash or folder:gmail-home/archive + +# mailing list tagging +notmuch tag +list +linux -- to:[email protected] +notmuch tag +list +devel +emacs -- to:[email protected] +notmuch tag +list +humanities +emacs -- to:[email protected] +notmuch tag +list +org +emacs -- to:[email protected] + +# remove new tag +notmuch tag -new -- tag:new countafter=$(notmuch count) added=$((countafter - countbefore)) +[ "$added" -lt 0 ] && added=0 -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 +notify-send --icon "$ICON" "Mail Sync Summary" "Added: $added\nTotal: $countafter" diff --git a/bin/.local/bin/scripts/cleanmail b/bin/.local/bin/scripts/cleanmail index 83d5c08..8b202e7 100755 --- a/bin/.local/bin/scripts/cleanmail +++ b/bin/.local/bin/scripts/cleanmail @@ -1,8 +1,13 @@ #!/usr/bin/env bash +ICON="/home/bard/dotfiles-stow/fvwm/.fvwm/icon/Yoritsuki/Kinchaku (drawstring bag).png" countbefore=$(notmuch count tag:del) + +# Only delete local files, don't sync back notmuch search --format=text0 --output=files tag:del | xargs -0 --no-run-if-empty rm notmuch new + countafter=$(notmuch count tag:del) +deleted=$((countbefore - countafter)) -notify-send "$countafter messages deleted" +notify-send --icon "$ICON" "Local trash cleaned" "$deleted local copies removed" |
