mailbox detect now searches all accounts

This commit is contained in:
Luke 2018-02-14 14:58:02 -07:00
parent 0f8c27918d
commit b09b3d2249

View File

@ -9,6 +9,8 @@ changePassword() { \
shred -u /tmp/$1 shred -u /tmp/$1
mv /tmp/$1.gpg ~/.config/mutt/credentials/ ;} mv /tmp/$1.gpg ~/.config/mutt/credentials/ ;}
chooseDetect() { for x in $(cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;'); do detectMailboxes $x; done && detectSuccess ;}
detectWarning() { \ detectWarning() { \
dialog --title "Mailbox detect requirement" --yesno "In order for the mailbox detection system to work, you must have dialog --title "Mailbox detect requirement" --yesno "In order for the mailbox detection system to work, you must have
@ -53,15 +55,17 @@ detectMailboxes() { \
echo "set record = \"$record\"" >> "$muttdir"accounts/$1.muttrc echo "set record = \"$record\"" >> "$muttdir"accounts/$1.muttrc
echo "set postponed = \"$postponed\"" >> "$muttdir"accounts/$1.muttrc ;} echo "set postponed = \"$postponed\"" >> "$muttdir"accounts/$1.muttrc ;}
# Sees what accounts have been generated bny the wizard # Get all accounts in ~/.offlineimaprc and load into variable `accounts`.
# by checking ~/.offlineimap and yields a menu of them. getAccounts() { \
inventory() { \
cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;' | nl --number-format=ln > /tmp/numbered
accounts=() accounts=()
while read n s ; do while read n s ; do
accounts+=($n "$s" off) accounts+=($n "$s" off)
done < /tmp/numbered done < /tmp/numbered ;}
# Yields a menu of available accounts.
inventory() { \
getAccounts
choices=$(dialog --separate-output --checklist "Choose an email account." 15 40 16 "${accounts[@]}" 2>&1 >/dev/tty) choices=$(dialog --separate-output --checklist "Choose an email account." 15 40 16 "${accounts[@]}" 2>&1 >/dev/tty)
if [ -z "$choices" ]; if [ -z "$choices" ];
@ -193,10 +197,10 @@ case $choice in
$(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g') $(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g')
" 6 60;; " 6 60;;
1) addChosen;; 1) addChosen;;
2) detectWarning && inventory && for i in $userchoices; do detectMailboxes $i ; done && detectSuccess;; 2) detectWarning && chooseDetect ;;
3) inventory && for i in $userchoices; do changePassword $i ; done;; 3) inventory && for i in $userchoices; do changePassword $i ; done;;
4) inventory && for i in $userchoices; do removeAccount $i ; done;; 4) inventory && for i in $userchoices; do removeAccount $i ; done;;
5) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;; 5) (dialog --defaultno --title "Wipe all custom neomutt/offlineIMAP settings?" --yesno "Would you like to wipe all of the mutt/offlineIMAP settings generated by the system?" 6 60 && wipe) ;;
6) clear && break 6) clear && break ;;
esac esac
done done