diff options
| author | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-24 19:24:55 -0500 |
|---|---|---|
| committer | Mohammad Reza Karimi <m.r.karimi.j@gmail.com> | 2026-01-24 19:24:55 -0500 |
| commit | e2a70a92822b22633562e9695c300efec2b5cbeb (patch) | |
| tree | fbd1658be1ab5edb1470d9a8e4b758818cc7124c /scripts/dot-local/bin/mailsync | |
| parent | 4052357e021085bc1c761108446ee09a778ade15 (diff) | |
updates
Diffstat (limited to 'scripts/dot-local/bin/mailsync')
| -rwxr-xr-x | scripts/dot-local/bin/mailsync | 4 |
1 files changed, 3 insertions, 1 deletions
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", $_)' | |
