commit 7234ceb2493a175eca7a93f453126f02efd06fa4
parent d69958dfa4a1d08012c19a5e4fad1ae5e9fbeba4
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Tue, 27 Oct 2020 11:30:33 +0100
mailsync: stop if password incorrect
Former-commit-id: 9506efe715a4eef0f07da282152e6f3028d827c5
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/mailsync b/scripts/mailsync
@@ -1,12 +1,14 @@
#!/bin/sh
-BW_SESSION="$(bw unlock --raw)"; export BW_SESSION
+BW_SESSION="${BW_SESSION:-$(bw unlock --raw)}"
+[ $? -eq 0 ] || { printf "Could not unlock vault.\n" && exit 1; }
+export BW_SESSION
mbsync -c /Users/alex/.config/mbsync/mbsyncrc -Va
notmuch new
notification_str=""
for i in ~/.local/share/mail/*/[Ii][Nn][Bb][Oo][Xx]/new; do
mailbox_name="$(printf "%s" "$i" | sed 's:^.*mail/::; s:/[Ii][Nn][Bb][Oo][Xx]/new.*$::')"
- num_new_messages="$(find "$i"/* -type f | wc -l)"
+ num_new_messages="$(find "$i"/* -type f 2>/dev/null | wc -l)"
[ "$num_new_messages" -gt 0 ] \
&& notification_str="${notification_str}
$(printf "%s: %d" "$mailbox_name" "$num_new_messages")"