mail: Fix mail-check hooks
Fixed running the hooks for `mail-check`. Command (or variable?) substition prevented the hooks from running completely beforehand, so I moved them to a separate function with the option remaining to call a custom script for them through environment variables. Ideally the env vars (`MBSYNC_PRE` and `MBSYNC_POST`) should only point to a single script each, as more involved commands will presumably fail to execute correctly when whitespace substition is involved. See more explanation here: https://unix.stackexchange.com/a/444949
This commit is contained in:
parent
b176b61b52
commit
407ad0473f
1 changed files with 19 additions and 4 deletions
|
@ -12,8 +12,23 @@
|
|||
# https://sourceforge.net/p/isync/feature-requests/8/
|
||||
|
||||
MBSYNC_MAX_TRIES=3
|
||||
MBSYNC_PRE="imapfilter -c /home/marty/.config/imapfilter/config.lua"
|
||||
MBSYNC_POST="notmuch new && afew --tag --new"
|
||||
|
||||
prehook() {
|
||||
if [ -n "$MBSYNC_PRE" ]; then
|
||||
eval "$MBSYNC_PRE"
|
||||
return 0
|
||||
fi
|
||||
imapfilter -c "${XDG_CONFIG_HOME:-/home/marty/.config}/imapfilter/config.lua"
|
||||
}
|
||||
|
||||
posthook() {
|
||||
if [ -n "$MBSYNC_POST" ]; then
|
||||
eval "$MBSYNC_POST"
|
||||
return 0
|
||||
fi
|
||||
notmuch new --quiet 2>/dev/null
|
||||
afew --tag --new
|
||||
}
|
||||
|
||||
# fail the routine and optionally send a message why
|
||||
fail() {
|
||||
|
@ -41,7 +56,7 @@ if [ "$1" = "raw" ]; then
|
|||
fi
|
||||
|
||||
main() {
|
||||
$MBSYNC_PRE
|
||||
prehook
|
||||
|
||||
tries=0
|
||||
while true; do
|
||||
|
@ -56,7 +71,7 @@ main() {
|
|||
done
|
||||
unset tries
|
||||
|
||||
$MBSYNC_POST
|
||||
posthook
|
||||
}
|
||||
|
||||
notmuch_foldertags() {
|
||||
|
|
Loading…
Reference in a new issue