Add support for our now primary fastmail account

While at it, add some macros to mutt and clean up shell script with
shellcheck.

We also stop running imapfilter for anything but our own accounts.
This commit is contained in:
Sanchayan Maity 2021-02-11 14:16:19 +05:30
parent 7652573b72
commit 2b89f36dc5
8 changed files with 139 additions and 55 deletions

View file

@ -1,4 +1,21 @@
function main() function main()
local fastmail = IMAP {
server = 'imap.fastmail.com',
username = 'maitysanchayan@fastmail.com',
password = get_pwd_fastmail(),
ssl = 'tls1',
}
fastmail.INBOX:check_status()
mails = fastmail.INBOX:select_all()
move_mailing_lists(fastmail, mails)
mails = fastmail.Sent:select_all()
move_mailing_lists(fastmail, mails)
mails = fastmail['Trash']:select_all()
move_mailing_lists(fastmail, mails)
mails = fastmail['Spam']:select_all()
move_mailing_lists(fastmail, mails)
local sanchayan = IMAP { local sanchayan = IMAP {
server = 'imap.gmail.com', server = 'imap.gmail.com',
username = 'maitysanchayan@gmail.com', username = 'maitysanchayan@gmail.com',
@ -19,28 +36,6 @@ function main()
delete_from_trash(sanchayan, mails) delete_from_trash(sanchayan, mails)
mails = sanchayan['[Gmail]/Spam']:select_all() mails = sanchayan['[Gmail]/Spam']:select_all()
move_mailing_lists(sanchayan, mails) move_mailing_lists(sanchayan, mails)
local asymptotic = IMAP {
server = 'imap.gmail.com',
username = 'sanchayan@asymptotic.io',
password = get_pwd_asymptotic(),
ssl = 'tls1',
}
asymptotic.INBOX:check_status()
-- asymptotic['[Gmail]/Trash']:check_status()
-- asymptotic['[Gmail]/Spam']:check_status()
mails = asymptotic.INBOX:select_all()
move_mailing_lists(asymptotic, mails)
mails = asymptotic.Sent:select_all()
move_mailing_lists(asymptotic, mails)
mails = asymptotic['[Gmail]/Trash']:select_all()
imap_trash = asymptotic['Trash']:select_all()
move_to_gmail_trash(asymptotic, imap_trash, '[Gmail]/Trash')
delete_from_trash(asymptotic, mails)
mails = asymptotic['[Gmail]/Spam']:select_all()
move_mailing_lists(asymptotic, mails)
end end
function move_mailing_lists(account, mails) function move_mailing_lists(account, mails)
@ -128,6 +123,14 @@ function get_imap_password(file)
return str; return str;
end end
function get_pwd_fastmail()
local cmd = "gpg2 --use-agent --quiet --batch --decrypt ~/.fastmail.gpg"
local fd = io.popen(cmd, 'r')
pass = fd:read("*a")
fd:close()
return pass;
end
function get_pwd_sanchayan() function get_pwd_sanchayan()
local cmd = "gpg2 --use-agent --quiet --batch --decrypt ~/.sanchayan.gpg" local cmd = "gpg2 --use-agent --quiet --batch --decrypt ~/.sanchayan.gpg"
local fd = io.popen(cmd, 'r') local fd = io.popen(cmd, 'r')
@ -136,12 +139,4 @@ function get_pwd_sanchayan()
return pass; return pass;
end end
function get_pwd_asymptotic()
local cmd = "gpg2 --use-agent --quiet --batch --decrypt ~/.asymptotic.gpg"
local fd = io.popen(cmd, 'r')
pass = fd:read("*a")
fd:close()
return pass;
end
main() -- Call the main function main() -- Call the main function

View file

@ -2,6 +2,32 @@ Create Slave
Expunge Both Expunge Both
SyncState * SyncState *
IMAPAccount fastmail
Host imap.fastmail.com
Port 993
User maitysanchayan@fastmail.com
PassCmd "gpg2 -q --for-your-eyes-only --no-tty -d ~/.fastmail.gpg"
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore fastmail-remote
Account fastmail
MaildirStore fastmail-local
SubFolders Verbatim
Path "~/Mail/fastmail/"
Inbox "~/Mail/fastmail/Inbox"
Channel fastmail
Master :fastmail-remote:
Slave :fastmail-local:
Patterns *
Expunge None
CopyArrivalDate yes
Sync All
Create Slave
SyncState *
IMAPAccount asymptotic IMAPAccount asymptotic
Host imap.gmail.com Host imap.gmail.com
Port 993 Port 993
@ -15,8 +41,8 @@ Account asymptotic
MaildirStore asymptotic-local MaildirStore asymptotic-local
SubFolders Verbatim SubFolders Verbatim
Path "~/Gmail/asymptotic/" Path "~/Mail/asymptotic/"
Inbox "~/Gmail/asymptotic/Inbox" Inbox "~/Mail/asymptotic/Inbox"
Channel asymptotic Channel asymptotic
Master :asymptotic-remote: Master :asymptotic-remote:
@ -35,8 +61,8 @@ Account gmail
MaildirStore gmail-local MaildirStore gmail-local
Subfolders Verbatim Subfolders Verbatim
Path "~/Gmail/sanchayan/" Path "~/Mail/sanchayan/"
Inbox "~/Gmail/sanchayan/Inbox" Inbox "~/Mail/sanchayan/Inbox"
Channel gmail Channel gmail
Master :gmail-remote: Master :gmail-remote:

View file

@ -7,6 +7,12 @@ auth on
tls on tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt tls_trust_file /etc/ssl/certs/ca-certificates.crt
account fastmail
host smtp.fastmail.com
from sanchayan@sanchayanmaity.net
user maitysanchayan@fastmail.com
passwordeval "gpg2 --use-agent --batch --quiet --no-greeting --no-tty --for-your-eyes-only --homedir /home/core/.gnupg --decrypt ~/.fastmail.gpg"
account Sanchayan account Sanchayan
host smtp.gmail.com host smtp.gmail.com
from maitysanchayan@gmail.com from maitysanchayan@gmail.com
@ -20,4 +26,4 @@ user sanchayan@asymptotic.io
passwordeval "gpg2 --use-agent --batch --quiet --no-greeting --no-tty --for-your-eyes-only --homedir /home/core/.gnupg --decrypt ~/.asymptotic.gpg" passwordeval "gpg2 --use-agent --batch --quiet --no-greeting --no-tty --for-your-eyes-only --homedir /home/core/.gnupg --decrypt ~/.asymptotic.gpg"
# Set a default account # Set a default account
account default : Sanchayan account default : fastmail

View file

@ -0,0 +1,21 @@
set from = "sanchayan@sanchayanmaity.net"
set sendmail = "/usr/bin/msmtp -a fastmail"
set mbox = "+fastmail/Archive"
set postponed = "+fastmail/drafts"
set record = "+fastmail/Sent"
color status green default
macro index D \
"<save-message>+fastmail/Trash<enter>" \
"move message to the trash"
macro index S \
"<save-message>+fastmail/Spam<enter>" \
"mark message as spam"
macro index gi "<change-folder>=fastmail/Inbox<enter>" "Go to Inbox"
macro index gf "<change-folder>=fastmail/FreedesktopGitlab<enter>" "Go to freedesktop gitlab"
macro index gg "<change-folder>=fastmail/gstreamer<enter>" "Go to gstreamer"
macro index gp "<change-folder>=fastmail/pulseaudio<enter>" "Go to pulseaudio"
macro index gs "<change-folder>=fastmail/Sent<enter>" "Go to Sent"

View file

@ -13,3 +13,9 @@ macro index D \
macro index S \ macro index S \
"<save-message>+sanchayan/Spam<enter>" \ "<save-message>+sanchayan/Spam<enter>" \
"mark message as spam" "mark message as spam"
macro index gi "<change-folder>=sanchayan/Inbox<enter>" "Go to Inbox"
macro index gf "<change-folder>=sanchayan/FreedesktopGitlab<enter>" "Go to freedesktop gitlab"
macro index gg "<change-folder>=sanchayan/gstreamer<enter>" "Go to gstreamer"
macro index gp "<change-folder>=sanchayan/pulseaudio<enter>" "Go to pulseaudio"
macro index gs "<change-folder>=sanchayan/Sent<enter>" "Go to Sent"

View file

@ -1,17 +1,31 @@
#!/bin/bash #!/bin/bash
imapfilter -c ~/.imapfilter/config.lua
mbsync -a
notmuch new
export DISPLAY=:0 export DISPLAY=:0
let inbox=`ls /home/core/Gmail/sanchayan/Inbox/new/|wc -l`
let asymptotic_inbox=`ls /home/core/Gmail/asymptotic/Inbox/new/|wc -l`
if [ "$inbox" -gt 0 ]; then imapfilter -c ~/.imapfilter/config.lua
sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have $inbox new mails in inbox"
if [ -d "$HOME/Mail/fastmail" ]; then
mbsync fastmail
fastmail_inbox=$(find ~/Mail/fastmail/Inbox/new | wc -l)
if [ "$fastmail_inbox" -gt 1 ]; then
notify-send "You have $fastmail_inbox new mails in fastmail inbox"
fi
fi fi
if [ "$asymptotic_inbox" -gt 0 ]; then if [ -d "$HOME/Mail/sanchayan" ]; then
sudo -u core DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "You have $asymptotic_inbox new mails in asymptotic inbox" mbsync gmail
gmail_inbox=$(find ~/Mail/sanchayan/Inbox/new | wc -l)
if [ "$gmail_inbox" -gt 1 ]; then
notify-send "You have $gmail_inbox new mails in gmail inbox"
fi
fi fi
if [ -d "$HOME/Mail/asymptotic" ]; then
mbsync asymptotic
asymptotic_inbox=$(find ~/Mail/asymptotic/Inbox/new | wc -l)
if [ "$asymptotic_inbox" -gt 1 ]; then
notify-send "You have $asymptotic_inbox new mails in asymptotic inbox"
fi
fi
notmuch new

View file

@ -1,11 +1,13 @@
set mbox_type = Maildir set mbox_type = Maildir
set folder = ~/Gmail set folder = ~/Mail
set spoolfile = +/sanchayan/Inbox set spoolfile = +/fastmail/Inbox
set header_cache=~/Gmail/mutt_cache/ # a much faster opening of mailboxes... set header_cache=~/Mail/mutt_cache/ # a much faster opening of mailboxes...
source ~/.mutt/accounts/fastmail
source ~/.mutt/accounts/sanchayan source ~/.mutt/accounts/sanchayan
source ~/.mutt/accounts/asymptotic source ~/.mutt/accounts/asymptotic
folder-hook fastmail/* source ~/.mutt/accounts/fastmail
folder-hook sanchayan/* source ~/.mutt/accounts/sanchayan folder-hook sanchayan/* source ~/.mutt/accounts/sanchayan
folder-hook asymptotic/* source ~/.mutt/accounts/asymptotic folder-hook asymptotic/* source ~/.mutt/accounts/asymptotic
@ -44,7 +46,6 @@ unignore from: to: cc: date: subject: # then, show only these
hdr_order from: to: cc: date: subject: # and in this order hdr_order from: to: cc: date: subject: # and in this order
source ~/.mutt/gruvbox.muttrc source ~/.mutt/gruvbox.muttrc
macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'
set send_charset="us-ascii:utf-8" set send_charset="us-ascii:utf-8"
set send_charset="utf-8" set send_charset="utf-8"
@ -75,4 +76,19 @@ macro index L "<enter-command>unset wait_key<enter><shell-escape>read -p 'notmuc
# 'a' shows all messages again (supersedes default <alias> binding) # 'a' shows all messages again (supersedes default <alias> binding)
macro index a "<limit>all\n" "show all messages (undo limit)" macro index a "<limit>all\n" "show all messages (undo limit)"
# macro index D "<save-message>+/Trash<enter>" "Move message to the trash" macro index C '<change-folder>?<change-dir><home>^K=<enter>'
macro index ca '<enter-command>source ~/.mutt/muttrc/accounts/asymptotic<enter><change-folder>=asymptotic/Inbox/<enter>'
macro index cf '<enter-command>source ~/.mutt/muttrc/accounts/fastmail<enter><change-folder>=fastmail/Inbox/<enter>'
macro index cg '<enter-command>source ~/.mutt/muttrc/accounts/sanchayan<enter><change-folder>=sanchayan/Inbox/<enter>'
macro index ,so "l ^a^k^O\n" "show old messages only"
macro index ,sn "l ^a^k~N\n" "show unread/new only"
macro index ,sf "l ~F\n" "show flagged messages only"
macro index ,si "l (~n5-100|~N)\n" "show higher scoring messages"
macro index ,hl "l ^a^k!~l\n" "hide list messages"
macro index ,sa "l ^a^kall\n" "show all messages"
bind pager \Cp previous-line
bind pager \Cn next-line
bind pager <up> previous-line
bind pager <down> next-line

View file

@ -11,7 +11,7 @@
# configured here named ".notmuch". # configured here named ".notmuch".
# #
[database] [database]
path=/home/core/Gmail path=/home/core/Mail
# User configuration # User configuration
# #
@ -30,8 +30,8 @@ path=/home/core/Gmail
# #
[user] [user]
name=Sanchayan Maity name=Sanchayan Maity
primary_email=sanchayan@asymptotic.io primary_email=maitysanchayan@fastmail.com
other_email=maitysanchayan@gmail.com; other_email=maitysanchayan@gmail.com;sanchayan@asymptotic.io
# Configuration for "notmuch new" # Configuration for "notmuch new"
# #
@ -49,7 +49,7 @@ other_email=maitysanchayan@gmail.com;
# #
[new] [new]
tags=N; tags=N;
ignore=mutt_cache ignore=mutt_cache;.mbsyncstate;.mbsyncstate.lock;.uidvalidity
# Search configuration # Search configuration
# #