[mail] feat: add filters for univ

This commit is contained in:
David JULIEN 2022-11-04 14:50:41 +01:00
parent fd74b462fb
commit 438c25f4ff
3 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
notmuch tag --input $XDG_CONFIG_HOME/notmuch/tags/univ

View File

@ -0,0 +1,27 @@
#!/usr/bin/env sh
# Archive files that are NOT tagged Inbox
accounts="univ"
# Update paths & tags
notmuch new --no-hooks
filter() {
notmuch search --output=files --format=text0 $parameters and tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/new/"
notmuch search --output=files --format=text0 $parameters and not tag:new| xargs -0 --no-run-if-empty mv -t "$XDG_DATA_HOME/mail/$account/$tag/cur/"
}
for account in $accounts
do
tags_location="$XDG_CONFIG_HOME/notmuch/tags/$account"
tags="$(grep "+" "$tags_location" | sed -e 's/^.//' -e 's/ .*//')"
for tag in $tags
do
[ "univ" = $tag ] && continue
parameters="folder:$account/INBOX and tag:$tag"
filter
done
done
# Update paths
notmuch new --no-hooks

View File

@ -16,9 +16,9 @@ do
new="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/$acc -path */new/* -type f | grep -iv -e "trash" -e "drafts" | wc -l 2>/dev/null)"
if [ $new -gt 0 ]; then
box=""
[ -n "$(echo "$acc" | sed -n '/@univ/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/@mailo/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/@posteo/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/univ/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/mailo/p')" ] && box=""
[ -n "$(echo "$acc" | sed -n '/posteo/p')" ] && box=""
unread="$unread/$box$new"
fi
done