summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-05-31 20:47:38 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-05-31 20:47:38 -0400
commit3d320f28c5e40d23da0468c04b6ed39eb95309a2 (patch)
treee93b75b478178593154fa4c0ace92aa49331d457 /bin
parent55f810ef6939d5aecd3bfb8a10b62c21ee484d23 (diff)
parentbb72cf5a71418a3d8eaa3cc731a2b8a8627e9c1c (diff)
Merge branch 'master' of github.com:LukeSmithxyz/mutt-wizard
Diffstat (limited to 'bin')
-rwxr-xr-xbin/mailsync8
-rwxr-xr-xbin/mw17
2 files changed, 17 insertions, 8 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 6ee7f51..a90c6c9 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -12,7 +12,7 @@ ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; e
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."
# Required to display notifications if run as a cronjob:
-DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
+export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
export DISPLAY=:0.0
# For individual configurations:
@@ -21,7 +21,7 @@ export DISPLAY=:0.0
# Settings are different for MacOS (Darwin) systems.
if [ "$(uname)" = "Darwin" ]; then
notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;}
- messageinfo() { osascript "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
+ messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\"" ;}
else
notify() { notify-send --app-name="mutt-wizard" "mutt-wizard" "📬 $2 new mail(s) in \`$1\` account." ;}
messageinfo() { notify-send --app-name="mutt-wizard" "📧$from:" "$subject" ;}
@@ -30,7 +30,7 @@ fi
# Check account for new mail. Notify if there is new content.
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
- mbsync $opts "$acc"
+ mbsync "$opts" "$acc"
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)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
if [ "$newcount" -gt "0" ]; then
@@ -38,7 +38,7 @@ syncandnotify() {
for file in $new; do
# Extract subject and sender from mail.
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
- subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
+ subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n 1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
messageinfo &
done
fi
diff --git a/bin/mw b/bin/mw
index 981f3d2..0862f30 100755
--- a/bin/mw
+++ b/bin/mw
@@ -3,11 +3,11 @@
command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
[ -z ${PASSWORD_STORE_DIR+x} ] && PASSWORD_STORE_DIR="$HOME/.password-store"
[ -r "$PASSWORD_STORE_DIR/.gpg-id" ] &&
- "$GPG" --list-secret-keys $(cat "$PASSWORD_STORE_DIR/.gpg-id") >/dev/null 2>&1 || {
+ "$GPG" --list-secret-keys "$(cat "$PASSWORD_STORE_DIR/.gpg-id")" >/dev/null 2>&1 || {
printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`%s --full-gen-key\` first.\\n" "$GPG"
exit
}
-! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
+! command -v mbsync >/dev/null && printf "\`mbsync (isync package)\` must be installed to run mutt-wizard.\\n" && exit
prefix="/usr/local"
muttdir="$HOME/.config/mutt" # Main mutt config location
@@ -86,6 +86,9 @@ set folder = \"$maildir/$title\"
set header_cache = $cachedir/$title/headers
set message_cachedir = $cachedir/$title/bodies
set mbox_type = Maildir
+set crypt_opportunistic_encrypt = yes
+set pgp_self_encrypt = yes
+set pgp_default_key = $keyid
bind index,pager gg noop
bind index,pager g noop
@@ -108,6 +111,11 @@ set header_cache = $cachedir/$title/headers
set message_cachedir = $cachedir/$title/bodies
set imap_pass = \"\`pass mutt-wizard-$title\`\"
+set crypt_opportunistic_encrypt = yes
+set pgp_self_encrypt = yes
+set pgp_default_key = $keyid
+
+
set mbox_type = Maildir
set ssl_starttls = yes
set ssl_force_tls = yes
@@ -126,6 +134,7 @@ fi
askinfo() { \
printf "Insert the \033[31memail address\033[0m that you want to autoconfigure for mutt/mbsync\\n\tEmail: \033[36m"
read -r fulladdr
+ keyid=$( gpg --list-keys --with-colons "$fulladdr" | awk -F: '/^pub:/ { print $5 }')
printf "\033[0m"
while ! echo "$fulladdr" | grep "$emailre" >/dev/null; do
printf "That is not a valid \033[31memail address\033[0m, please retype the desired email.\\n\\nEmail: \033[36m\t"
@@ -136,7 +145,7 @@ askinfo() { \
search_query=$domain
case "$domain" in
protonmail.com|protonmail.ch|pm.me)
- search_query='protonmail.com' && break;;
+ search_query='protonmail.com' && return 1;;
*)
while : ; do
printf "\nIs your email hosted with Protonmail? [yes/no] "
@@ -330,7 +339,7 @@ synchronize_flags=true
gpg_path=$GPG"
echo "$nmbasic" > "$NOTMUCH_CONFIG" ;}
-trap 'echo -e "\033[0m\n"; exit' STOP INT ABRT KILL
+trap 'echo -e "\033[0m\n"; exit' INT ABRT
case "$1" in
ls) list ;;