From 3049b27fa5c7874db802b8fbdf2e016abe87fd9e Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 5 Mar 2018 23:38:22 -0700 Subject: notify system added --- mutt-wizard.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'mutt-wizard.sh') diff --git a/mutt-wizard.sh b/mutt-wizard.sh index 4946775..7fb5413 100755 --- a/mutt-wizard.sh +++ b/mutt-wizard.sh @@ -2,6 +2,15 @@ muttdir="$HOME/.config/mutt/" +chooseSync() { (crontab -l && testSync) || dialog --msgbox "No cronjob manager detected. Please install one and return to enable automatic mailsyncing" 10 60 ;} +testSync() { (crontab -l | grep .config/mutt/etc/mailsync && removeSync) || addSync ;} + +addSync() { min=$(dialog --inputbox "How many minutes should be between mail syncs?" 8 60 3>&1 1>&2 2>&3 3>&-) + (crontab -l; echo "*/$min * * * * /home/$(whoami)/.config/mutt/etc/mailsync.sh") | crontab - && + dialog --msgbox "Cronjob successfully added. Remember you may need to restart or tell systemd/etc. to start your cron manager for this to take effect." 7 60 ;} + +removeSync() { ((crontab -l | sed -e '/.config\/mutt\/etc\/mailsync/d') | crontab - >/dev/null) && dialog --msgbox "Cronjob successfully removed. To reactivate, select this option again." 6 60 ;} + changePassword() { \ gpgemail=$( dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your GPG key pair. This is NOT necessarily the email you want to configure." 10 60 3>&1 1>&2 2>&3 3>&- ) dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the new password for the \"$1\" account." 10 60 2> /tmp/$1 @@ -206,14 +215,15 @@ wipe () { rm $HOME/.offlineimaprc while : ; do choice=$(dialog --title "Luke's mutt/offlineIMAP wizard" --nocancel \ - --menu "What would you like to do?" 14 45 7 \ + --menu "What would you like to do?" 16 45 8 \ 0 "List all email accounts configured." \ 1 "Add an email account." \ 2 "Auto-detect mailboxes for an account." \ - 3 "Change an account's password." \ - 4 "Remove an email account." \ - 5 "Remove all email accounts." \ - 6 "Exit this wizard." \ + 3 "Enable/disable autosync." \ + 4 "Change an account's password." \ + 5 "Remove an email account." \ + 6 "Remove all email accounts." \ + 7 "Exit this wizard." \ 3>&1 1>&2 2>&3 3>&1 ) case $choice in @@ -222,9 +232,10 @@ $(grep ~/.offlineimaprc -e "^accounts =" | sed 's/accounts =//g') " 6 60;; 1) chooseAdd;; 2) detectWarning && chooseDetect ;; -3) inventory && for i in $userchoices; do changePassword $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) ;; -6) clear && break ;; +3) chooseSync;; +4) inventory && for i in $userchoices; do changePassword $i ; done;; +5) inventory && for i in $userchoices; do removeAccount $i ; done;; +6) (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) ;; +7) clear && break ;; esac done -- cgit v1.2.3