diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mailsync | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/mailsync b/bin/mailsync index d33ec23..801aaeb 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -19,7 +19,7 @@ pgrep mbsync >/dev/null && { echo "mbsync is already running."; exit ;} # files for variable assignments. This is ugly, but there are few options that # will work on the maximum number of machines. eval "$(grep -h -- \ - "^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\|MAILSYNC_MUTE\)=" \ + "^\s*\(export \)\?\(MBSYNCRC\|MPOPRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\|MAILSYNC_MUTE\)=" \ "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \ "$HOME/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \ "$HOME/.pam_environment" 2>/dev/null)" @@ -27,6 +27,7 @@ eval "$(grep -h -- \ export GPG_TTY="$(tty)" [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" +[ -n "$MPOPRC" ] || MPOPRC="$HOME/.config/mpop/config" lastrun="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" @@ -35,7 +36,7 @@ lastrun="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun" [ -z "$MAILSYNC_MUTE" ] && notify="$(uname)" || notify="mute" case "$notify" in mute) - notify() { echo "notifications disabled" >/dev/null ;} + notify() { : ;} ;; Darwin) notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} @@ -57,7 +58,13 @@ esac # 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 [ "$1" = "pop" ]; then + # Handle POP + mpop "$acc" + else + # Handle IMAP + if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi + fi new=$(find\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/new/\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/cur/\ @@ -75,11 +82,17 @@ if [ "$#" -gt "0" ]; then done accounts=$* fi +# TODO handle account passed from argument [ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" +[ -z "$pop_accounts" ] && pop_accounts="$(awk '/^account/ {print $2}' "$MPOPRC")" # Parallelize multiple accounts for account in $accounts; do - syncandnotify & + syncandnotify "imap" & +done + +for account in $pop_accounts; do + syncandnotify "pop" & done wait |