From: Christian Heller Date: Thu, 16 May 2019 21:06:44 +0000 (+0200) Subject: Improve mail setup. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/calendar?a=commitdiff_plain;h=2c18bcbb13809e4b89f0b6d01b11ca5d8765b95d;p=config Improve mail setup. --- diff --git a/buster/home_files/user_eeepc/.mbsyncrc b/buster/home_files/user_eeepc/.mbsyncrc index cab35a7..d3d3d88 100644 --- a/buster/home_files/user_eeepc/.mbsyncrc +++ b/buster/home_files/user_eeepc/.mbsyncrc @@ -24,3 +24,5 @@ Patterns * Create Both # Save the synchronization state files in the relevant directory SyncState * +# If a mail is marked T ("Trashed") or deleted, remove it for real everywhere +Expunge Both diff --git a/buster/home_files/user_eeepc/.notmuch-config b/buster/home_files/user_eeepc/.notmuch-config new file mode 100644 index 0000000..230bbe3 --- /dev/null +++ b/buster/home_files/user_eeepc/.notmuch-config @@ -0,0 +1,4 @@ +[database] +path=/home/plom/mail +[search] +exclude_tags=deleted;spam; diff --git a/buster/home_files/user_eeepc/mail_sync.sh b/buster/home_files/user_eeepc/mail_sync.sh new file mode 100755 index 0000000..d20690d --- /dev/null +++ b/buster/home_files/user_eeepc/mail_sync.sh @@ -0,0 +1,29 @@ +#!/bin/sh +set -e + +# Ensure all "dir:*"-tagged mails are in proper directories. +basedir="/home/plom/test_mbsync/maildir/" +for tag in $(notmuch search --output=tags '*'); do + if [ ! $(echo "${tag}" | cut -c-4) = "dir:" ]; then + continue + fi + target_dir="${basedir}"$(echo "${tag}" | cut -c5-)"/cur/" + for f in $(notmuch search --output=files tag:"${tag}"); do + new_name=$(basename "${f}" | sed -e 's/,U=[0-9]*//') + target_path="${target_dir}${new_name}" + if [ ! "${target_path}" = "${f}" ]; then + echo "Moving ${f} to ${target_path}." + mv "${f}" "${target_path}" + fi + done +done + +# Remove all "deleted"-tagged files from maildirs. +notmuch search --output=files tag:deleted | while read f; do + echo "Deleting ${f}" + rm "${f}" +done + +# Sync changes back to server and update notmuch index. +mbsync -a +notmuch new