From e2a70a92822b22633562e9695c300efec2b5cbeb Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Sat, 24 Jan 2026 19:24:55 -0500 Subject: updates --- scripts/dot-local/bin/mailsync | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/dot-local/bin/mailsync') diff --git a/scripts/dot-local/bin/mailsync b/scripts/dot-local/bin/mailsync index 7e16626..be2f93d 100755 --- a/scripts/dot-local/bin/mailsync +++ b/scripts/dot-local/bin/mailsync @@ -8,7 +8,7 @@ fi mbsync_running() { - account_escaped=$(printf '%s\n' "$1" | sed 's/[.[\*^$()+?{|\\]/\\&/g') + local account_escaped=$(printf '%s\n' "$1" | sed 's/[.[\*^$()+?{|\\]/\\&/g') pgrep -f "^mbsync([[:space:]]+[^ ]+)*[[:space:]]+$account_escaped($|[[:space:]])" >/dev/null || pgrep -f "^mbsync([[:space:]]+[^ ]+)*[[:space:]]+-a($|[[:space:]])" >/dev/null @@ -53,6 +53,7 @@ sync_and_notify() { mbsync $mbsync_flag "$1" + local new newcount new=$(fd --type f --changed-after "@$time_lastrun" . "$MAILDIR/$1/INBOX/new/" "$MAILDIR/$1/INBOX/cur/" 2>/dev/null) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) @@ -64,6 +65,7 @@ sync_and_notify() $((newcount > 0))) echo "$newcount new mail for $1." for file in $new; do + local subject from # Extract and decode subject and sender from mail. subject=$(awk '/^Subject: / && ++n == 1,/^.*: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | -- cgit v1.2.3-71-gdd5e