aboutsummaryrefslogtreecommitdiff
path: root/bin/.local
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2026-04-01 17:58:37 -0400
committerBardofSprites <[email protected]>2026-04-01 17:58:37 -0400
commit709b062decb3db2aec3c74e686c3b6009a2c4272 (patch)
tree622a348b45986ebd00c04330b91ab5cce8200b8b /bin/.local
parent2d1e340c17d52b0c88761f30736747875ddf29d8 (diff)
huge update to email scripts
Diffstat (limited to 'bin/.local')
-rwxr-xr-xbin/.local/bin/scripts/checkmail43
-rwxr-xr-xbin/.local/bin/scripts/cleanmail7
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"