diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/mw | 35 | 
1 files changed, 10 insertions, 25 deletions
| @@ -97,7 +97,7 @@ bind index,pager g noop  bind index,pager M noop  bind index,pager C noop  bind index gg first-entry -macro index o \"<shell-escape>mailsync -V $title<enter>\" \"run mbsync to sync $title\" +macro index o \"<shell-escape>mbsync -V $title<enter>\" \"run mbsync to sync $title\"  unmailboxes *  "  else @@ -286,27 +286,6 @@ delete() { sed -ibu "/IMAPStore $title-remote$/,/# End profile/d" "$mbsyncrc" ;  	sed -ibu "/account $title/,/^\(\s*$\|account\)/d" "$msmtprc"; rm -f "$msmtprc"bu  	} -choosecron() { ! pgrep cron >/dev/null && echo "No cron manager running. Install/enable one and then select this option again." && return 1 -	if crontab -l | grep mailsync >/dev/null; then -		echo "Active mail sync cronjob detected. Do you want to remove it?" -		printf "\033[36m\t" -		read -r rmyn -		printf "\033[0m" -		echo "$rmyn" | grep -i "^y\(es\)*$" >/dev/null && crontab -l | sed '/mailsync/d' | crontab - >/dev/null && echo "Mail sync turned off." -	else -		echo "How many minutes between each mail sync?" -		printf "\033[36m\t" -		read -r minnum -		printf "\033[0m" -		while ! echo "$minnum" | grep "^[0-9]\+$" >/dev/null; do -			printf "That doesn't look like a number. How many minutes between each mail sync?\\n\033[36m\t" -			read -r minnum -			printf "\033[0m" -		done -		(crontab -l; echo "*/$minnum * * * * $(type mailsync | cut -d' ' -f3) >/dev/null 2>&1") | crontab - >/dev/null && -			echo "Cronjob added. Mail will sync every $minnum minutes. Be sure you have your cron manager running." -	fi ;} -  asktype() { while : ; do  		printf "Do you want to keep your mail for this account offline with mbsync? [yes/no]\\n\t"  		read -r offnot @@ -318,11 +297,17 @@ asktype() { while : ; do  purge() { confirm "delete all account data" || exit  	rm -rf "$mbsyncrc" "$accdir" "$HOME/.config/msmtp" "$cachedir" -	crontab -l | sed '/mailsync/d' | crontab - >/dev/null  	echo "All configs and account settings have been purged."  	sed -ibu "/\# mw-autogenerated/d" "$muttrc" ; rm -f "$muttrc"bu  } +syncwrapper() { mbsync -a & +	( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null +	wait +	( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null +	notmuch new +} +  notmuchauto() { \  	[ -z "$NOTMUCH_CONFIG" ] && NOTMUCH_CONFIG="$HOME/.notmuch-config"  	[ -f "$NOTMUCH_CONFIG" ] && return 0 @@ -349,8 +334,8 @@ case "$1" in  	add) asktype && askinfo && tryconnect && finalize || delete ;;  	pass) pick "change the password of" && getpass ;;  	delete) pick delete && confirm "delete the \`$title\` profile" && delete ;; +	sync) syncwrapper ;;  	purge) purge ;; -	cron) choosecron ;;  	*) cat << EOF  mw: mutt-wizard, auto-configure email accounts for mutt  including downloadable mail with \`isync\`. @@ -360,7 +345,7 @@ Allowed options:    ls		List configured accounts    delete	Pick an account to delete    purge		Delete all accounts and settings -  cron		Enable or disable an autosync via cronjob +  sync		Syncs mail and updates notmuch database    all else	Print this message  NOTE: Once at least one account is added, you can run | 
