From b11dcf53dccd33725c7458e884eeb6aa30dcaa4e Mon Sep 17 00:00:00 2001 From: dgrisham Date: Mon, 18 Jan 2021 15:56:28 -0700 Subject: [PATCH] mailsync: Check whether XDG_CONFIG_HOME is defined before defaulting to $HOME/.config for mutt dir --- bin/mailsync | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/mailsync b/bin/mailsync index 980b015..ecac6af 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -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"