Browse Source

Merge pull request #884 from parin23/pop3-notification-fix

Add Support for POP3 Notification
pull/891/head
Luke Smith 1 year ago
committed by GitHub
parent
commit
b2bf553567
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      bin/mailsync

+ 16
- 3
bin/mailsync View File

@@ -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 # files for variable assignments. This is ugly, but there are few options that
# will work on the maximum number of machines. # will work on the maximum number of machines.
eval "$(grep -h -- \ eval "$(grep -h -- \
"^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \
"^\s*\(export \)\?\(MBSYNCRC\|MPOPRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \
"$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.config/zsh/.zprofile" "$HOME/.zshenv" \ "$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/.config/zsh/.zshenv" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.config/zsh/.zshrc" \
"$HOME/.pam_environment" 2>/dev/null)" "$HOME/.pam_environment" 2>/dev/null)"
@@ -27,6 +27,7 @@ eval "$(grep -h -- \
export GPG_TTY="$(tty)" export GPG_TTY="$(tty)"


[ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" [ -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" lastrun="${XDG_CONFIG_HOME:-$HOME/.config}/mutt/.mailsynclastrun"


@@ -52,7 +53,13 @@ esac
# Check account for new mail. Notify if there is new content. # Check account for new mail. Notify if there is new content.
syncandnotify() { syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")" 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\ new=$(find\
"$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/new/\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/new/\
"$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/cur/\ "$HOME/.local/share/mail/$acc/"[Ii][Nn][Bb][Oo][Xx]/cur/\
@@ -70,11 +77,17 @@ if [ "$#" -gt "0" ]; then
done done
accounts=$* accounts=$*
fi fi
# TODO handle account passed from argument
[ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")" [ -z "$accounts" ] && accounts="$(awk '/^Channel/ {print $2}' "$MBSYNCRC")"
[ -z "$pop_accounts" ] && pop_accounts="$(awk '/^account/ {print $2}' "$MPOPRC")"


# Parallelize multiple accounts # Parallelize multiple accounts
for account in $accounts; do for account in $accounts; do
syncandnotify &
syncandnotify "imap" &
done

for account in $pop_accounts; do
syncandnotify "pop" &
done done


wait wait


Loading…
Cancel
Save