summaryrefslogtreecommitdiff
path: root/bin/mw
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mw')
-rwxr-xr-xbin/mw29
1 files changed, 21 insertions, 8 deletions
diff --git a/bin/mw b/bin/mw
index 44086be..2101cdd 100755
--- a/bin/mw
+++ b/bin/mw
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
set -a
@@ -12,12 +12,14 @@ msmtprc="${XDG_CONFIG_HOME:-$HOME/.config}/msmtp/config"
msmtplog="${XDG_STATE_HOME:-$HOME/.local/state}/msmtp/msmtp.log"
mbsyncrc="${MBSYNCRC:-$HOME/.mbsyncrc}"
mpoprc="${XDG_CONFIG_HOME:-$HOME/.config}/mpop/config"
+imapnotify="${XDG_CONFIG_HOME:-$HOME/.config}/imapnotify"
mpoptemp="$muttshare/mpop-temp"
mbsynctemp="$muttshare/mbsync-temp"
mutttemp="$muttshare/mutt-temp"
msmtptemp="$muttshare/msmtp-temp"
onlinetemp="$muttshare/online-temp"
notmuchtemp="$muttshare/notmuch-temp"
+imapnotifytemp="$muttshare/imapnotify-temp"
# With the use of templates, it's impossible to use parameter substitution.
# Therefore, some default variables that might be otherwise overwritten are set
# here.
@@ -29,14 +31,19 @@ maxmes="0"
alias mbsync='mbsync -c "$mbsyncrc"'
-# mbsync now requires "Far/Near" rather than "Master/Slave", but Ubuntu/Debian
-# have the older version.
-if command -V apt-get >/dev/null 2>&1; then
- master="Master"
- slave="Slave"
-else
+# mbsync >=1.4.0 requires "Far/Near" rather than "Master/Slave."
+mbver="$(mbsync -v)"
+mbver="${mbver#* }"
+mbver="${mbver%.*}"
+# Comparing two float numbers in bash is a pain in the butt, so we get rid of
+# dots and turn them into nice integers
+mbver="${mbver/\./}"
+if [ "${mbver}" -gt 14 ]; then
master="Far"
slave="Near"
+else
+ master="Master"
+ slave="Slave"
fi
for x in "/etc/ssl/certs/ca-certificates.crt" \
@@ -78,6 +85,10 @@ prepmpop() {
envsubst <"$mpoptemp" >>"$mpoprc"
}
+prepimapnotify() {
+ mkdir -p "$imapnotify" ; envsubst < "$imapnotifytemp" >> "$imapnotify/$fulladdr.conf"
+}
+
prepmutt() {
mkdir -p "${muttrc%/*}" "$accdir"
envsubst <"$mutttemp" >"$accdir/$fulladdr.muttrc"
@@ -85,6 +96,7 @@ prepmutt() {
! grep -q "^source.*mutt-wizard.muttrc" "$muttrc" && echo "source $muttshare/mutt-wizard.muttrc" >>"$muttrc"
! grep "^source.*.muttrc" "$muttrc" | grep -qv "$muttshare/mutt-wizard.muttrc" && echo "source $accdir/$fulladdr.muttrc" >>"$muttrc"
echo "macro index,pager i$idnum '<sync-mailbox><enter-command>source $accdir/$fulladdr.muttrc<enter><change-folder>!<enter>;<check-stats>' \"switch to $fulladdr\"" >>"$muttrc"
+ neomutt -v | grep -q lmdb && ! grep -q "^set header_cache_backend.*lmdb" "$muttrc" && echo "set header_cache_backend = \"lmdb\"" >>"$muttrc"
}
getprofiles() {
@@ -106,6 +118,7 @@ getprofiles() {
prepmsmtp
prepmutt
prepnotmuch
+ prepimapnotify
}
parsedomains() {
@@ -181,7 +194,7 @@ askinfo() {
}
insertpass() {
- printf "%s" "$password" | pass insert -fe "$PASSWORD_STORE_DIR/$passprefix$fulladdr"
+ printf "%s" "$password" | pass insert -fe "$passprefix$fulladdr"
}
errorexit() {