diff options
author | Luke Smith <luke@lukesmith.xyz> | 2021-01-24 08:28:50 -0500 |
---|---|---|
committer | Luke Smith <luke@lukesmith.xyz> | 2021-01-24 08:28:50 -0500 |
commit | 039dec817e2f6f8a0ab3f886dfeeba4aecf2b2cf (patch) | |
tree | 2e32e5a3d0903da30136c3defda78d1a6ccd0b12 /bin | |
parent | b56686aae5721da0f26bfac28b97635a363896e7 (diff) | |
parent | 3bd61cbc9753f43765f5c866a53437a0d60e4f8f (diff) |
Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mailsync | 8 | ||||
-rwxr-xr-x | bin/mw | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/bin/mailsync b/bin/mailsync index c939347..7bad83d 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -22,7 +22,7 @@ pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} # will work on the maximum number of machines. eval "$(grep -h -- \ "^\s*\(export \)\?\(MBSYNCRC\|PASSWORD_STORE_DIR\|NOTMUCH_CONFIG\|GNUPGHOME\)=" \ - "$HOME/.profile" "$HOME/.bash_profile" "$HOME/.zprofile" "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.pam_environment" 2>/dev/null)" + "$HOME/.profile" "$HOME/.bash_profile" "${ZDOTDIR:-$HOME}/.zprofile" "$HOME/.bashrc" "${ZDOTDIR:-$HOME}/.zshrc" "$HOME/.pam_environment" 2>/dev/null)" # One alternative to this kind of command would be marking the script for # /bin/sh -l. That might cause other problems on other particular setups that # do more complicated things on login, or those people who assign environmental @@ -33,6 +33,8 @@ case "$(readlink -f /sbin/init)" in esac export GPG_TTY=$TTY +muttconfig="${XDG_CONFIG_HOME:-$HOME/.config}/mutt" + [ -n "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC" || MBSYNCRC="$HOME/.mbsyncrc" # Settings are different for MacOS (Darwin) systems. @@ -58,7 +60,7 @@ esac syncandnotify() { acc="$(echo "$account" | sed "s/.*\///")" if [ -z "$opts" ]; then mbsync "$acc"; else mbsync "$opts" "$acc"; fi - new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/.mailsynclastrun" 2> /dev/null) + new=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$muttconfig/.mailsynclastrun" 2> /dev/null) newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) if [ "$newcount" -gt "0" ]; then notify "$acc" "$newcount" & @@ -91,4 +93,4 @@ wait notmuch new 2>/dev/null #Create a touch file that indicates the time of the last run of mailsync -touch "$HOME/.config/mutt/.mailsynclastrun" +touch "$muttconfig/.mailsynclastrun" @@ -25,7 +25,7 @@ checkbasics() { command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2" [ -r "$PASSWORD_STORE_DIR/.gpg-id" ] && "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || { echo "First run \`pass init <yourgpgemail>\` to set up a password archive." - echo "(If you don't already have a GPG key pair, first run \`$GPG --fullgenkey\`.)" + echo "(If you don't already have a GPG key pair, first run \`$GPG --full-gen-key\`.)" exit 1 ;} ;} getaccounts() { accounts="$(find -L "$accdir" -type f | grep -o "[0-9]-.*.muttrc" | sed "s/-/: /;s/\.muttrc$//" | sort -n)" ;} @@ -122,6 +122,7 @@ bind index,pager g noop bind index,pager M noop bind index,pager C noop bind index gg first-entry +unmacro index o unmailboxes * " fi @@ -236,7 +237,7 @@ Junk Trash Sent Archive" && return 0 - info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap")" + info="$(curl --location-trusted -s -m 5 --user "$login:$(pass $pass_prefix$fulladdr)" --url "${protocol:-imaps}://$imap:${iport:-993}")" [ -z "$info" ] && echo "Log-on not successful." && return 1 mailboxes="$(echo "$info" | sed "s/.*\" //;s/\"//g" | tr -d '
')" } @@ -351,6 +352,7 @@ while getopts "fplhodTYD:y:i:I:s:S:u:a:n:x:m:t:" o; do case "${o}" in t) setact toggle || exit 1 ; cronmin="$OPTARG" ;; T) setact toggle || exit 1 ;; p) echo "NOTE: Protonmail users must install and configure Protonmail Bridge first for the first sync to work." + protocol="imap" imap="127.0.0.1" iport="1143" smtp="127.0.0.1" |