| @@ -177,8 +177,7 @@ formatShortcut() { \ | |||||
| echo "macro index,pager C$1 \"<copy-message>$data<enter>\" \"Copy mail to $2.\" # autogenerated"; } >> "$muttdir/accounts/$3.muttrc" | echo "macro index,pager C$1 \"<copy-message>$data<enter>\" \"Copy mail to $2.\" # autogenerated"; } >> "$muttdir/accounts/$3.muttrc" | ||||
| done ;} | done ;} | ||||
| trysync() { \ | |||||
| ! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning \`mbsync %s\` manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" "$title" && return 1 | |||||
| trysync() { ! ping -q -c 1 1.1.1.1 > /dev/null && printf "No internet connection detected.\\nTry rerunning \`mbsync %s\` manually when connection is established, then select the option to detect mailboxes and finalize installation.\\n" "$title" && return 1 | |||||
| printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-wizard will run mbsync briefly to (1) ensure that login details are functional and (2) allow mbsync to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run mbsync manually to finish the mail sync later.\\n" | printf "\033[32mYou must have an internet connection to continue.\033[0m\\nmutt-wizard will run mbsync briefly to (1) ensure that login details are functional and (2) allow mbsync to tell us what mailboxes your email account has.\\nAfter around 15 seconds, mutt-wizard will kill the process and continue.\\nYou can run mbsync manually to finish the mail sync later.\\n" | ||||
| cont | cont | ||||
| mkdir -p "$maildir/$title" | mkdir -p "$maildir/$title" | ||||
| @@ -224,7 +223,6 @@ confirm() { printf "Are you \033[31;1mreally\033[0m sure you want to %s?\\n\t" " | |||||
| printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 | printf "Are you really, really sure you want to %s?\\n\t" "$@" && read -r input && ! echo "$input" | grep -i "y\(es\)*" >/dev/null && printf "That doesn't seem like a yes to me.\\n\\n" && return 1 | ||||
| return 0 ;} | return 0 ;} | ||||
| pick() { numbered="$(ls $accdir/*muttrc | sed "s/.*\///;s/\..*//" | nl)" | pick() { numbered="$(ls $accdir/*muttrc | sed "s/.*\///;s/\..*//" | nl)" | ||||
| [ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No accounts to choose from.\\n" && return 1 | [ "$(echo "$numbered" | wc -w)" = 0 ] && printf "No accounts to choose from.\\n" && return 1 | ||||
| printf "Select an accounts to %s:\\n" "$1" | printf "Select an accounts to %s:\\n" "$1" | ||||
| @@ -241,7 +239,6 @@ delete() { sed -i "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" | |||||
| rm -rf "${accdir:?}/${title:?}" "$accdir/$title.muttrc" | rm -rf "${accdir:?}/${title:?}" "$accdir/$title.muttrc" | ||||
| sed -i "/$title.muttrc/d" "$muttdir/personal.muttrc" | sed -i "/$title.muttrc/d" "$muttdir/personal.muttrc" | ||||
| sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config" | sed -i "/account $title/,/^\(\s*$\|account\)/d" "$HOME/.config/msmtp/config" | ||||
| #confirm "delete the local mail repository as well?" && rm -rf "${maildir:?}/${title:?}" | |||||
| } | } | ||||
| choosecron() { ! pgrep crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 | choosecron() { ! pgrep crond >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 | ||||
| @@ -263,16 +260,14 @@ choosecron() { ! pgrep crond >/dev/null && echo "No cron manager running. Instal | |||||
| done | done | ||||
| (crontab -l; echo "*/$minnum * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . \$HOME/.profile; $muttdir/bin/mailsync") | crontab - && | (crontab -l; echo "*/$minnum * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus; export DISPLAY=:0; . \$HOME/.profile; $muttdir/bin/mailsync") | crontab - && | ||||
| echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running." | echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running." | ||||
| fi | |||||
| } | |||||
| fi ;} | |||||
| cont() { printf "Press Enter to continue.\\n" | cont() { printf "Press Enter to continue.\\n" | ||||
| stty -echo | stty -echo | ||||
| read -r null | read -r null | ||||
| stty echo ; } | stty echo ; } | ||||
| addtype() { \ | |||||
| ! command -v mbsync >/dev/null && printf "You must have the \`mbsync\` command to add an account.\\nIt syncs mail and detects remote mailboxes.\\nYou can typically get it by installing \`isync\`.\\n" && return 1 | |||||
| addtype() { ! command -v mbsync >/dev/null && printf "You must have the \`mbsync\` command to add an account.\\nIt syncs mail and detects remote mailboxes.\\nYou can typically get it by installing \`isync\`.\\n" && return 1 | |||||
| while : ; do | while : ; do | ||||
| echo "Do you want to keep your mail for this account offline with mbsync? [yes/no]" | echo "Do you want to keep your mail for this account offline with mbsync? [yes/no]" | ||||
| read -r offnot | read -r offnot | ||||
| @@ -282,11 +277,9 @@ addtype() { \ | |||||
| *) echo "I don't know what you mean. Try again or press ctrl-c to quit." ;; | *) echo "I don't know what you mean. Try again or press ctrl-c to quit." ;; | ||||
| esac | esac | ||||
| done | done | ||||
| addaccount | |||||
| } | |||||
| addaccount ;} | |||||
| main() { \ | |||||
| while : ; do | |||||
| main() { while : ; do | |||||
| printf "Welcome to:\\n\033[34m" | printf "Welcome to:\\n\033[34m" | ||||
| cat << "EOF" | cat << "EOF" | ||||
| _ __ ___ _ _| |_| |_ __ _(_)______ _ _ __ __| | | _ __ ___ _ _| |_| |_ __ _(_)______ _ _ __ __| | | ||||
| @@ -318,8 +311,7 @@ Input a number to continue or press ctrl-c.\\n" | |||||
| *) printf "Invalid input.\\n" | *) printf "Invalid input.\\n" | ||||
| esac | esac | ||||
| cont | cont | ||||
| done | |||||
| } | |||||
| done ;} | |||||
| main | main | ||||
| rm -rf "$tmpdir" | rm -rf "$tmpdir" | ||||