From 85321514af8344b44b92fb5ef988f1f65f0fd027 Mon Sep 17 00:00:00 2001 From: thehnm Date: Tue, 30 Jun 2020 23:32:32 +0200 Subject: [PATCH] Add possibility to read mbsyncrc in user config The mbsync command inside mailsync has to be modified in order to read the isync config file in .config/isync/mbsyncrc. If no file is found, the config is read in the default location. --- bin/mailsync | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/mailsync b/bin/mailsync index 93ec35d..5a72a2f 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -17,6 +17,7 @@ export DISPLAY=:0.0 # For individual configurations: [ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" +[ -f "$HOME/.config/isync/mbsyncrc" ] && MBSYNC="mbsync -c \"$HOME/.config/isync/mbsyncrc\"" || MBSYNC="mbsync" # Settings are different for MacOS (Darwin) systems. if [ "$(uname)" = "Darwin" ]; then @@ -30,7 +31,7 @@ fi # Check account for new mail. Notify if there is new content. syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" - if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + if [ -z "$opts" ]; then eval "$MBSYNC $acc"; else eval "$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) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then @@ -46,7 +47,7 @@ syncandnotify() { # Sync accounts passed as argument or all. if [ "$#" -eq "0" ]; then - accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")" + [ -f "$HOME/.config/isync/mbsyncrc" ] && accounts="$(awk '/^Channel/ {print $2}' "$HOME/.config/isync/mbsyncrc")" || accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")" else for arg in "$@"; do [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1