diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mailsync | 15 | ||||
-rwxr-xr-x | bin/mw | 13 |
2 files changed, 18 insertions, 10 deletions
diff --git a/bin/mailsync b/bin/mailsync index 9c7f457..3a681f0 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -48,7 +48,7 @@ case "$(uname)" in notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-:0}; do export DISPLAY="$x" - notify-send --app-name="mutt-wizard" "$1" "$2" + notify-send --app-name="mutt-wizard" -- "$1" "$2" done ;} ;; esac @@ -66,16 +66,17 @@ syncandnotify() { newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) case 1 in $((newcount > 5)) ) - echo "$newcount new mail for $2." - [ -z "$MAILSYNC_MUTE" ] && notify "New Mail!" "📬 $newcount new mail(s) in \`$2\` account." + echo "$newcount new mails for $2." >/dev/tty + [ -z "$MAILSYNC_MUTE" ] && notify "New Mail!" "📬 $newcount new mails in \`$2\` account." ;; $((newcount > 0)) ) - echo "$newcount new mail for $2." + echo "$newcount new mail(s) for $2." >/dev/tty [ -z "$MAILSYNC_MUTE" ] && for file in $new; do - # Extract and decode subject and sender from mail. - subject="$(sed -n "/^Subject:/ s|Subject: *|| p" "$file" | - perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" + # Extract and decode subject and sender from mail. + subject=$(awk '/^Subject: / && ++n == 1,/^.*: / && ++i == 2' "$file" | head -n-1 | + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | + sed 's/^Subject: //' | tr -d '\n\t') from="$(sed -n "/^From:/ s|From: *|| p" "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)')" from="${from% *}" ; from="${from%\"}" ; from="${from#\"}" @@ -12,12 +12,14 @@ msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config" msmtplog="${XDG_STATE_HOME:-$HOME/.local/state}/msmtp/msmtp.log" mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}" mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config" +imapnotify="${XDG_CONFIG_HOME:-$HOME/.config}/imapnotify" mpoptemp="$muttshare/mpop-temp" mbsynctemp="$muttshare/mbsync-temp" mutttemp="$muttshare/mutt-temp" msmtptemp="$muttshare/msmtp-temp" onlinetemp="$muttshare/online-temp" notmuchtemp="$muttshare/notmuch-temp" +imapnotifytemp="$muttshare/imapnotify-temp" # With the use of templates, it's impossible to use parameter substitution. # Therefore, some default variables that might be otherwise overwritten are set # here. @@ -78,6 +80,10 @@ prepmpop() { envsubst <"$mpoptemp" >>"$mpoprc" } +prepimapnotify() { + mkdir -p "${imapnotify%/*}" ; envsubst < "$imapnotifytemp" >> "$imapnotify/$fulladdr.conf" +} + prepmutt() { mkdir -p "${muttrc%/*}" "$accdir" envsubst <"$mutttemp" >"$accdir/$fulladdr.muttrc" @@ -106,6 +112,7 @@ getprofiles() { prepmsmtp prepmutt prepnotmuch + prepimapnotify } parsedomains() { @@ -173,11 +180,11 @@ askinfo() { [ -z "$passprefix" ] && passprefix="" hostname="${fulladdr#*@}" login="${login:-$fulladdr}" - if [ -n "${password+x}" ]; then + if [ -n "${password+x}" ] && [ ! -f "$PASSWORD_STORE_DIR/$passprefix$fulladdr.gpg" ]; then insertpass - else + elif [ ! -f "$PASSWORD_STORE_DIR/$passprefix$fulladdr.gpg" ]; then getpass - fi + fi } insertpass() { |