2 Commits

Author SHA1 Message Date
  Luke Smith 85c5d01dcd
mw -r to reorder account numbers 2 years ago
  Luke Smith 418565eb94
minor tweaks 2 years ago
4 changed files with 32 additions and 6 deletions
Split View
  1. +1
    -0
      README.md
  2. +1
    -1
      bin/mailsync
  3. +27
    -5
      bin/mw
  4. +3
    -0
      mw.1

+ 1
- 0
README.md View File

@@ -79,6 +79,7 @@ The mutt-wizard runs via the command `mw`. Once setup is complete, you'll use
- `mw -D your@email.com` -- delete account settings without confirmation
- `mw -t 30` -- toggle automatic mailsync to every 30 minutes
- `mw -T` -- toggle mailsync without specifying minutes (default is 10)
- `mw -r` -- reorder account shortcut numbers
- `pass edit mw-your@email.com` -- revise an account's password

### Options usable when adding an account


+ 1
- 1
bin/mailsync View File

@@ -43,7 +43,7 @@ case "$(uname)" in
displays="$(echo "$pgrepoutput" | grep -wo "[0-9]*:[0-9]\+" | sort -u)"
notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-0:}; do
export DISPLAY=$x
notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account."
notify-send --app-name="mutt-wizard" "New mail!" "📬 $2 new mail(s) in \`$1\` account."
done ;}
;;
esac


+ 27
- 5
bin/mw View File

@@ -198,7 +198,7 @@ askinfo() { \
read -r smtp
[ "$sport" = 587 ] && tlsline="# tls_starttls"
[ -z "$realname" ] && realname="${fulladdr%%@*}"
hostname="$(echo "$fulladdr" | cut -d @ -f 2)"
hostname="${fulladdr#*@}"
login="${login:-$fulladdr}"
if [ -n "${password+x}" ]; then
createpass
@@ -222,9 +222,9 @@ getboxes() { if [ -n "${force+x}" ] ; then
mailboxes="$(echo "$info" | grep -v HasChildren | sed "s/.*\" //;s/\"//g" | tr -d '\r')"
fi
[ "$type" = "pop" ] && mailboxes="INBOX"
for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " $muttrc | sort -u; echo 0); do
for x in $(sed -n "/^macro.* i[0-9] / s/\(^macro.* i\| .*\)//gp " "$muttrc" | sort -u; echo 0); do
idnum=$((idnum + 1))
[ $idnum -eq $x ] || break
[ "$idnum" -eq "$x" ] || break
done
toappend="mailboxes \`mdir=$maildir/$fulladdr/; find \$mdir -mindepth 1 -type d -name cur | sed -e 's:/cur\$:\":' -e \"s:\$mdir:\\\"=:\" | sort | tr '\\\n' ' '\`"
}
@@ -285,6 +285,7 @@ Main actions:
-Y Sync mail for all accounts
-t number Toggle automatic mailsync every <number> minutes
-T Toggle automatic mailsync
-r Reorder account numbers

Options allowed with -a:
-u Account login name if not full address
@@ -307,8 +308,28 @@ To change an account's password, run \`pass edit your@email.com\`.
EOF
}

while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
reorder(){
tempfile="$(mktemp -u)"
trap 'rm -f $tempfile' HUP INT QUIT TERM PWR EXIT
echo "# Carefully reorder these accounts with the desired numbers." > "$tempfile"
sed -n "
/ i[0-9] / s?\(.* i\|'<sync.*/\|\.muttrc.*\)??g p
" "$muttrc" > "$tempfile"
${EDITOR:-vim} "$tempfile" || exit 1
default="$(sort -n "$tempfile" | head -n 1)"
default="${default#* }"
sed -ibu "/.* i[0-9] .*.muttrc/d" "$muttrc" 2>/dev/null; rm -f "$muttrc"bu
awk -v a="$accdir" -v d="$default" ' BEGIN { print "source "a"/"d".muttrc" }
{
print "macro index,pager i"$1" '\''<sync-mailbox><enter-command>source "a"/"$2".muttrc<enter><change-folder>!<enter>;<check-stats>'\'' \"switch to "$2"\""
}
' "$tempfile" >> "$muttrc"

}

while getopts "rfpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
l) setact list || exit 1 ;;
r) setact reorder || exit 1 ;;
d) setact delete || exit 1 ;;
D) setact delete || exit 1 ; fulladdr="$OPTARG" ;;
y) setact sync || exit 1 ; fulladdr="$OPTARG" ;;
@@ -335,7 +356,7 @@ while getopts "fpPXlhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in
smtp="127.0.0.1"
sport="1025"
auth="login"
tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | awk '/SHA256:/ {print $2}')"
tlsline="tls_fingerprint $(msmtp --serverinfo --host=$smtp --port=$sport --tls --tls-certcheck=off | sed -n '/SHA256:/ s/^\s*SHA256:\s*// p')"
setact add || exit 1
;;
*) mwinfo; exit 1 ;;
@@ -347,5 +368,6 @@ case "$action" in
delete) delete ;;
sync) mailsync $fulladdr ;;
toggle) togglecron ;;
reorder) reorder ;;
*) mwinfo; exit 1 ;;
esac

+ 3
- 0
mw.1 View File

@@ -41,6 +41,9 @@ toggle a cronjob that syncs your mail every 15 minutes (or any other number unde
.TP
.B -T
toggle a cronjob without specifying minutes between sync
.TP
.B -r
reorder account shortcut numbers
.SH OPTIONS FOR ADDING ACCOUNTS
These can be specified on the command line, otherwise, you will be prompted for what is necessary. mutt-wizard knows the IMAP/SMTP server information for most email providers, so specifying them is usually redundant.
.TP


Loading…
Cancel
Save