neomutt: support up to 10 accounts

This commit is contained in:
lelgenio 2021-03-02 02:01:31 -03:00
parent 0976ab1b0e
commit 9e470ef8ef
6 changed files with 96 additions and 45 deletions

View File

@ -10,7 +10,6 @@ variables:
###############################################################
username: lelgenio
mail: disroot.org
cursor_size: 24
editor: kak
tabs: false
@ -33,6 +32,14 @@ variables:
medium: 14
big: 16
mail:
personal:
user: lelgenio
mail: disroot.org
work:
user: leonardo
mail: wopus.com.br
###############################################################
profiles:
###############################################################

View File

@ -1,25 +1,27 @@
IMAPStore mail-remote
Host {{@@ mail @@}}
{%@@ for name, info in mail.items() | reverse @@%}
IMAPStore {{@@ name @@}}-remote
Host {{@@ info.mail @@}}
Port 993
User {{@@ username @@}}@{{@@ mail @@}}
PassCmd "_get-pass {{@@ mail @@}}"
User {{@@ info.user @@}}@{{@@ info.mail @@}}
PassCmd "_get-pass {{@@ info.mail @@}}"
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt
MaildirStore mail-local
MaildirStore {{@@ name @@}}-local
Subfolders Verbatim
Path ~/.local/share/mail/
Inbox ~/.local/share/mail/INBOX
Path ~/.local/share/mail/{{@@ name @@}}/
Inbox ~/.local/share/mail/{{@@ name @@}}/INBOX
Flatten .
Channel mail-remote
Channel {{@@ name @@}}
Expunge Both
Master :mail-remote:
Slave :mail-local:
Master :{{@@ name @@}}-remote:
Slave :{{@@ name @@}}-local:
Patterns * !"[Gmail]/All Mail"
Create Both
SyncState *
# MaxMessages 0
# End profile
{%@@ endfor @@%}
# vim: ft=sh

View File

@ -6,36 +6,32 @@
# |_| \_|\___|\___/|_| |_| |_|\__,_|\__|\__|
set my_user='{{@@ username @@}}'
set my_host='{{@@ mail @@}}'
set my_pass=`_get-pass "$my_host"`
# Mailbox {{{
set realname = "$my_user"
set from = "${my_user}@${my_host}"
# Set MailDir
set mbox_type = Maildir
set folder = ~/.local/share/mail
set header_cache = ~/.cache/mutt/
# set Mailboxes
set spoolfile = "+INBOX"
set record = "+Sent"
set postponed = "+Drafts"
set trash = "+Trash"
mailboxes \
`echo ~/.local/share/mail/INBOX*` \
"=Sent" \
"=Drafts" \
"=Trash" \
set my_mailroot = ~/.local/share/mail
set use_from = yes
set smtp_url = "smtps://${my_user}:${my_pass}@${my_host}"
set ssl_force_tls = yes
{%@@ for name, info in mail.items() | reverse @@%}
set my_source_command = \
"_get-mutt-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |"
folder-hook "$my_mailroot/{{@@ name @@}}/" \
source "\"$my_source_command\""
source "$my_source_command"
{%@@ endfor @@%}
{%@@ for name, info in mail.items() @@%}
set my_source_command = \
"_get-mutt-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |"
macro index,pager <f{{@@ loop.index @@}}> "<sync-mailbox><enter-command>source \"$my_source_command\"<enter><change-folder>!<enter>"
{%@@ endfor @@%}
# }}}
# General {{{

View File

@ -1,6 +1,6 @@
[{{@@ mail.strip("mail.").split(".")[0] @@}}]
[{{@@ mail.personal.mail.strip("mail.").split(".")[0] @@}}]
type = webdav
vendor = nextcloud
user = {{@@ username @@}}
pass = {{@@ rclone_obscure(mail) @@}}
url = https://cloud.{{@@ mail @@}}/remote.php/webdav/
pass = {{@@ rclone_obscure(mail.personal.mail) @@}}
url = https://cloud.{{@@ mail.personal.mail @@}}/remote.php/webdav/

28
dotfiles/scripts/_get-mutt-mail Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
my_path="$1"
my_user="$2"
my_host="$3"
my_pass=`_get-pass "$my_host"`
cat <<EOF
set realname = "$my_user"
set from = "${my_user}@${my_host}"
set smtp_url = "smtps://${my_user}:${my_pass}@${my_host}"
# set Mailboxes
set folder = ~/.local/share/mail/${my_path}/
set spoolfile = "+INBOX"
set record = "+Sent"
set postponed = "+Drafts"
set trash = "+Trash"
unmailboxes *
mailboxes \
`echo ~/.local/share/mail/${my_path}/INBOX*` \
"=Sent" \
"=Drafts" \
"=Trash" \
EOF

View File

@ -1,16 +1,25 @@
#!/bin/sh
set -e
test "$XDG_CURRENT_DESKTOP" = "gnome" &&
exit 0
if pidof gnome-shell
then
exit 0
fi
test -z "$XDG_RUNTIME_DIR" &&
export XDG_RUNTIME_DIR=/run/user/$(id -u)
die() {
test "$?" = 0 ||
notify-send "Failed to sync mail" "try unlocking your gpg key"
}
trap die EXIT
getnew(){
pushd "$HOME/.local/share/mail/" > /dev/null
find INBOX*/new -type f |
find */INBOX*/new -type f |
sed -E '/Duolingo|LBRY/d' |
wc -l
popd > /dev/null
@ -18,19 +27,28 @@ getnew(){
OLD=$(getnew)
[ "$1" = "update" ] &&
if test "$1" = "update"
then
mbsync -a ||
mbsync -a ||
mbsync -a
fi
NEW=$(getnew)
[ "$NEW" -gt "$OLD" ] &&
if test "$NEW" -gt "$OLD"
then
notify-send " New E-Mails!"
fi
echo $NEW | sed 's/^0$//'
[ "$(ps -o comm= $PPID)" != "waybar" ] &&
pidof waybar>/dev/null &&
pkill -SIGRTMIN+4 waybar
caller=`ps -o comm= $PPID`
if test "$caller" != "waybar"
then
pidof waybar>/dev/null &&
pkill -SIGRTMIN+4 waybar
fi
# vim:ft=sh