summaryrefslogtreecommitdiff
path: root/bin/mailsync
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2021-01-24 08:28:50 -0500
committerLuke Smith <luke@lukesmith.xyz>2021-01-24 08:28:50 -0500
commit039dec817e2f6f8a0ab3f886dfeeba4aecf2b2cf (patch)
tree2e32e5a3d0903da30136c3defda78d1a6ccd0b12 /bin/mailsync
parentb56686aae5721da0f26bfac28b97635a363896e7 (diff)
parent3bd61cbc9753f43765f5c866a53437a0d60e4f8f (diff)
Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard
Diffstat (limited to 'bin/mailsync')
-rwxr-xr-xbin/mailsync8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/mailsync b/bin/mailsync
index c939347..7bad83d 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -22,7 +22,7 @@ pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;}
# will work on the maximum number of machines.
eval "$(grep -h -- \
"^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \
- "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.pam_environment" 2>/dev/null)"
+ "$HOME/.profile" "$HOME/.bash_profile" "${ZDOTDIR:-$HOME}/.zprofile" "$HOME/.bashrc" "${ZDOTDIR:-$HOME}/.zshrc" "$HOME/.pam_environment" 2>/dev/null)"
# One alternative to this kind of command would be marking the script for
# /bin/sh -l. That might cause other problems on other particular setups that
# do more complicated things on login, or those people who assign environmental
@@ -33,6 +33,8 @@ case "$(readlink -f /sbin/init)" in
esac
export GPG_TTY=$TTY
+muttconfig="${XDG_CONFIG_HOME:-$HOME/.config}/mutt"
+
[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc"
# Settings are different for MacOS (Darwin) systems.
@@ -58,7 +60,7 @@ esac
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi
- new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null)
+ new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$muttconfig/.mailsynclastrun" 2> /dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
if [ "$newcount" -gt "0" ]; then
notify "$acc" "$newcount" &
@@ -91,4 +93,4 @@ wait
notmuch new 2>/dev/null
#Create a touch file that indicates the time of the last run of mailsync
-touch "$HOME/.config/mutt/.mailsynclastrun"
+touch "$muttconfig/.mailsynclastrun"