aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2025-07-31 14:43:06 -0400
committerBardofSprites <[email protected]>2025-07-31 14:43:06 -0400
commita5af07262cdd45bdf5461cef069fd12eb7b22ce6 (patch)
treedd960b5cff661f218f83256663565393a379fbd9 /bin
parent151e96f8be8982a594a7043ad1e7e94a5b07a2bf (diff)
update mail workflow
Diffstat (limited to 'bin')
-rwxr-xr-xbin/.local/bin/scripts/checkmail33
-rwxr-xr-xbin/.local/bin/scripts/cleanmail4
-rwxr-xr-xbin/.local/bin/scripts/perl/checkmail13
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, ">>")
-}