aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-11-12 16:05:32 -0300
committerEuAndreh <eu@euandre.org>2022-11-12 16:05:32 -0300
commit3dcbe37baab74e089dee6f93d74a8824f5591478 (patch)
tree64a8fc3d24b246c5d2018feda924d0f106e147cb
parentbin/bins: Add -F option (diff)
downloaddotfiles-3dcbe37baab74e089dee6f93d74a8824f5591478.tar.gz
dotfiles-3dcbe37baab74e089dee6f93d74a8824f5591478.tar.xz
Revert "Move email, IRC and Atom into Thunderbird"
This reverts commit 9e65133659eb92c65c730b83d68c81e9d2df4251. I'm still using msmtpq for git-send-email. So I'll have to work that out before removing *all* email configuration.
-rw-r--r--Makefile38
-rwxr-xr-xbin/m66
-rwxr-xr-xbin/mailcfg297
-rwxr-xr-xbin/update1
-rw-r--r--etc/guix/home.scm2
-rw-r--r--etc/mailcaps/config1
-rw-r--r--etc/sh/rc3
7 files changed, 407 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 036eda9..a9df1f2 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,14 @@ derived-assets = \
$(XDG_CONFIG_HOME)/ssh/id_rsa.pub \
$(XDG_CONFIG_HOME)/git/config-extra \
$(XDG_CONFIG_HOME)/gnupg/gpg-agent.conf \
+ $(XDG_CONFIG_HOME)/remhind/config \
$(XDG_CONFIG_HOME)/ssh/config \
+ $(XDG_CONFIG_HOME)/alot/config \
+ $(XDG_CONFIG_HOME)/mbsync/config \
+ $(XDG_CONFIG_HOME)/msmtp/config \
+ $(XDG_CONFIG_HOME)/notmuch/default/config \
+ $(XDG_CONFIG_HOME)/notmuch/default/hooks/post-new \
+ $(XDG_DATA_HOME)/euandreh/mailcfg-accounts.txt \
$(XDG_DATA_HOME)/common-lisp/source \
$(XDG_DATA_HOME)/euandreh/e.list.txt \
$(lisp-images)
@@ -34,10 +41,32 @@ share/man/man1/z.1: bin/z
$(XDG_DATA_HOME)/common-lisp/source:
ln -s $(SRC)/libre $@
+$(XDG_CONFIG_HOME)/alot/config: bin/mailcfg
+ mailcfg alot > $@
+
+$(XDG_CONFIG_HOME)/mbsync/config: bin/mailcfg
+ mailcfg mbsync > $@
+
+$(XDG_CONFIG_HOME)/msmtp/config: bin/mailcfg
+ mailcfg msmtp > $@
+
+$(XDG_CONFIG_HOME)/notmuch/default/config: bin/mailcfg
+ mailcfg notmuchcfg > $@
+
+$(XDG_CONFIG_HOME)/notmuch/default/hooks/post-new: bin/mailcfg
+ mailcfg notmuchhook > $@
+ chmod +x $@
+
+$(XDG_DATA_HOME)/euandreh/mailcfg-accounts.txt: bin/mailcfg
+ mailcfg list > $@
+
$(XDG_CONFIG_HOME)/ssh/id_rsa.pub:
gpg --export-ssh-key eu@euandre.org > $@
chmod 600 $@
+$(XDG_CONFIG_HOME)/remhind/config: $(XDG_CONFIG_HOME)/remhind/config.tmpl
+ envsubst < $(XDG_CONFIG_HOME)/remhind/config.tmpl > $@
+
$(XDG_CONFIG_HOME)/ssh/config: $(XDG_CONFIG_HOME)/ssh/config.tmpl
envsubst < $(XDG_CONFIG_HOME)/ssh/config.tmpl > $@
@@ -85,6 +114,13 @@ check-dirty-public:
exit 1; \
fi
+check-dirty-private:
+ if ! git -C $(PRIV_CONFIG) diff --quiet || \
+ ! git -C $(PRIV_CONFIG) diff --quiet --staged; then \
+ printf 'Dirty private tilde repository.\n' >&2; \
+ exit 1; \
+ fi
+
check-opt:
find opt/tests/ -name '*.sh' -exec {} +
@@ -98,7 +134,7 @@ check-sync:
fi
check: check-shellcheck check-perlcritic check-fixme check-dirty-public \
- check-opt check-pod check-sync
+ check-dirty-private check-opt check-pod check-sync
clean:
rm -f $(derived-assets)
diff --git a/bin/m b/bin/m
new file mode 100755
index 0000000..6891128
--- /dev/null
+++ b/bin/m
@@ -0,0 +1,66 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ m
+ m -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+
+ Fetch email via IMAP and update the notmuch index.
+
+
+ Examples:
+
+ Just fetch email
+
+ $ m
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+F="${XDG_DATA_HOME:-$HOME/.local/share}"/euandreh/mailcfg-accounts.txt
+
+notmuch new
+xargs -I% -P "$(wc -l < "$F")" mbsync '%' < "$F"
+notmuch new
diff --git a/bin/mailcfg b/bin/mailcfg
new file mode 100755
index 0000000..f77355e
--- /dev/null
+++ b/bin/mailcfg
@@ -0,0 +1,297 @@
+#!/bin/sh
+# shellcheck disable=1090,2153
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ mailcfg ACTION
+ mailcfg -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+ ACTION one of:
+ - mbsync
+ - msmtp
+ - notmuchcfg
+ - notmuchhook
+ - alot
+ - list
+
+
+ Emit the generated configuration file for the chosen email
+ program. Get the configuration files from
+ $XDG_CONFIG_HOME/mailcfg/*.env, where every *.env file is a
+ shell script that defines the variables used in this program:
+ - $NAME
+ - $LABEL
+ - $IMAP
+ - $SMTP
+ - $ADDR
+
+ One of the files also needs to define:
+ - $DEFAULT_NAME
+ - $DEFAULT_ADDR
+ - $DEFAULT_LABEL
+
+ An example of such file could be "30-andre@work.com.env":
+
+ #!/bin/sh
+ set -eu
+
+
+ NAME='André!'
+ LABEL='Work'
+ IMAP='imap.work.com'
+ SMTP='smtp.work.com'
+ ADDR='andre@work.com'
+
+
+ Examples:
+
+ Get the alot configuration file:
+
+ $ mailcfg alot
+
+
+ List the existing account labels:
+
+ $ mailcfg list
+ EOF
+}
+
+
+for flag; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+ACTION="${1:-}"
+eval "$(assert-arg "$ACTION" 'ACTION')"
+
+CFGDIR="${XDG_CONFIG_HOME:-$HOME/.config}/mailcfg"
+
+
+mbsync() {
+ cat <<-'EOF'
+ SyncState *
+ Create Both
+ Expunge Both
+ Remove Both
+ Sync All
+ EOF
+
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ cat <<-EOF
+
+
+ ## $LABEL
+
+ IMAPAccount $LABEL
+ Host $IMAP
+ User $ADDR
+ PassCmd "pass show $ADDR"
+ SSLType IMAPS
+
+ IMAPStore ${LABEL}Remote
+ Account $LABEL
+
+ MaildirStore ${LABEL}Local
+ Path ~/Maildir/$LABEL/
+ Inbox ~/Maildir/$LABEL/INBOX
+ SubFolders Verbatim
+
+ Channel ${LABEL}Folders
+ Far :${LABEL}Remote:
+ Near :${LABEL}Local:
+ Patterns *
+
+ Group $LABEL
+ Channel ${LABEL}Folders
+ EOF
+ done
+}
+
+msmtp() {
+ cat <<-EOF
+ defaults
+ auth on
+ tls on
+ port 587
+ syslog on
+ logfile $XDG_LOG_HOME/msmtp.log
+ EOF
+
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ cat <<-EOF
+
+ account $LABEL
+ host $SMTP
+ from $ADDR
+ user $ADDR
+ passwordeval pass show $ADDR
+ EOF
+ done
+
+ cat <<-EOF
+
+ account default : $DEFAULT_LABEL
+ EOF
+}
+
+notmuchcfg() {
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ done
+
+ cat <<-EOF
+ [user]
+ name = $DEFAULT_NAME
+ primary_email = $DEFAULT_ADDR
+ EOF
+
+ printf 'other_email = '
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ if [ "$ADDR" = "$DEFAULT_ADDR" ]; then
+ continue
+ fi
+ echo "$ADDR"
+ done | paste -sd';'
+
+ cat <<-'EOF'
+
+ [new]
+ tags = new;
+ ignore = .mbsyncstate;.uidvalidity
+
+ [search]
+ exclude_tags = deleted;spam
+
+ [maildir]
+ synchronize_flags = true
+ EOF
+}
+
+notmuchhook() {
+ LABELS=''
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ if [ -z "$LABELS" ]; then
+ LABELS="$LABEL"
+ else
+ LABELS="$LABELS $LABEL"
+ fi
+ done
+ sed \
+ -e "s|@DIRS@|$LABELS|g" \
+ -e "s|@DEFAULT_LABEL@|$DEFAULT_LABEL|g" \
+ "$CFGDIR"/post-new
+}
+
+alot() {
+ cat <<-'EOF'
+ attachment_prefix = "~/Downloads/"
+
+ [bindings]
+ i = toggletags inbox
+ I = search folder:/INBOX/ AND NOT tag:killed AND NOT tag:archive
+ EOF
+ echo "
+ z archive
+ s spam
+ u unread
+ r keep
+ t track
+ " | while read -r l; do
+ if [ -z "$l" ]; then
+ continue
+ fi
+ LC="$( echo "$l" | cut -d' ' -f1)"
+ TAG="$(echo "$l" | cut -d' ' -f2)"
+ UC="$(echo "$LC" | tr '[:lower:]' '[:upper:]')"
+ cat <<-EOF
+ $LC = toggletags $TAG
+ $UC = search tag:$TAG AND NOT tag:killed
+ EOF
+ done
+
+ cat <<-'EOF'
+ M = search folder:/lists/ AND NOT tag:killed
+ m = compose --tags inbox
+ [[thread]]
+ v = pipeto urlscan 2>/dev/null
+ V = pipeto 'gpg -d | less'
+ r = reply --all
+ R = reply
+ ' ' = fold; untag unread; move next unfolded
+ P = pipeto 'git am'
+
+ [accounts]
+ EOF
+
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ cat <<-EOF
+ [[$LABEL]]
+ realname = $NAME
+ address = $ADDR
+ sendmail_command = msmtpq --account=$LABEL -t
+ sent_box = maildir://~/Maildir/$LABEL/Sent
+ draft_box = maildir://~/Maildir/$LABEL/Drafts
+ gpg_key = 5BDAE9B8B2F6C6BCBB0D6CE581F90EC3CD356060
+ EOF
+ done
+}
+
+list() {
+ for env in "$CFGDIR"/*.env; do
+ . "$env"
+ printf '%s\n' "$LABEL"
+ done
+}
+
+
+case "$ACTION" in
+ mbsync|msmtp|notmuchcfg|notmuchhook|alot|list)
+ "$1"
+ ;;
+ *)
+ printf 'Unsupported ACTION: "%s".\n\n' "$ACTION" >&2
+ usage >&2
+ exit 2
+ ;;
+esac
diff --git a/bin/update b/bin/update
index 26bd5c7..11ac73d 100755
--- a/bin/update
+++ b/bin/update
@@ -74,6 +74,7 @@ guix pull &
wait
rfc -u
+newsboat -x reload
repos -e ~/dev/go/ -e ~/dev/quicklisp/ -e ~/dev/archive/ ~/dev/ |
xargs -I% -P4 x \
diff --git a/etc/guix/home.scm b/etc/guix/home.scm
index 79bb1c1..3bf9f3e 100644
--- a/etc/guix/home.scm
+++ b/etc/guix/home.scm
@@ -227,7 +227,9 @@
(define cronjobs
(list
+ #~(job "0 0 * * *" "cronjob msmtp-queue -r")
#~(job "0 0 * * *" "cronjob check")
+ #~(job "5 */6 * * *" "cronjob m")
#~(job "30 0 * * *" "cronjob x update AND upgrade")
#~(job "30 0 * * *" "cronjob backup -q cron")))
diff --git a/etc/mailcaps/config b/etc/mailcaps/config
new file mode 100644
index 0000000..60f7286
--- /dev/null
+++ b/etc/mailcaps/config
@@ -0,0 +1 @@
+text/html; env HOME=$XDG_DATA_HOME/w3m w3m -dump -o document_charset=%{charset} '%s'; nametemplate=%s.html; copiousoutput
diff --git a/etc/sh/rc b/etc/sh/rc
index 44e8efb..742975c 100644
--- a/etc/sh/rc
+++ b/etc/sh/rc
@@ -53,7 +53,9 @@ export GUILE_HISTORY="$XDG_STATE_HOME/guile-history"
export GNUPGHOME="$XDG_CONFIG_HOME/gnupg"
export RLWRAP_HOME="$XDG_CACHE_HOME/rlwrap"
export LESSHISTFILE="$XDG_STATE_HOME/lesshst"
+export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/default/config"
export PASSWORD_STORE_DIR="$SRC/private/password-store"
+export MAILCAPS="$XDG_CONFIG_HOME/mailcaps/config"
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc.py"
export EXINIT='
" set number
@@ -106,6 +108,7 @@ unalias -a
alias p='ping euandre.org -c 3'
alias c='tmux send-keys -R \; clear-history'
alias o='open'
+alias mm='msmtp-queue -r'
alias s='vcs status'
alias d='vcs diff'
alias ds='vcs diff -- --staged'