diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-27 19:06:29 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-27 19:06:29 -0500 |
commit | 6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2 (patch) | |
tree | 98297a53d3e8642dcc001c073f5b1d73590c58f0 | |
parent | 579e180c033d102859fdb74495170a743cecc3a0 (diff) | |
download | conf-6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2.tar.gz conf-6ad5f1cfda26c41fb1b7d06030c1918c06a3aad2.zip |
switch from offlineimap to mbsync
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | Makefile.hornet | 11 | ||||
-rwxr-xr-x | bin/hornet/update-mail | 11 | ||||
-rwxr-xr-x | bin/mbsyncloop | 42 | ||||
-rw-r--r-- | config/offlineimap/config | 34 | ||||
-rw-r--r-- | config/offlineimap/pass.py | 5 | ||||
-rw-r--r-- | mbsyncrc | 27 | ||||
-rwxr-xr-x | mutt/choose-muttrc-type | 2 | ||||
-rw-r--r-- | mutt/local (renamed from mutt/offlineimap) | 2 | ||||
-rw-r--r-- | notmuch-config | 3 | ||||
-rwxr-xr-x | services/available/mbsyncloop/log/run | 4 | ||||
-rwxr-xr-x | services/available/mbsyncloop/run | 3 | ||||
-rwxr-xr-x | services/available/offlineimap/log/run | 4 | ||||
-rwxr-xr-x | services/available/offlineimap/run | 3 |
15 files changed, 90 insertions, 64 deletions
@@ -3,5 +3,6 @@ /hammerspoon/hs /local/share/fortune/*.dat /less +/mbsyncloop /mpdscribble/mpdscribble.conf /vim/spell/*.spl @@ -41,7 +41,7 @@ INSTALL := \ .mutt/imap \ .mutt/mailcap \ .mutt/muttrc \ - .mutt/offlineimap \ + .mutt/local \ .nethackrc \ .profile \ .replyrc \ diff --git a/Makefile.hornet b/Makefile.hornet index 49917bd..b79144d 100644 --- a/Makefile.hornet +++ b/Makefile.hornet @@ -7,9 +7,9 @@ INSTALL := \ .config/i3/terminal-workspace.json \ .config/i3status/config \ .config/msmtp/config \ - .config/offlineimap/config \ - .config/offlineimap/pass.py \ .config/perspektiv/config.toml \ + .mbsyncrc \ + .mbsyncloop \ .mpdscribble \ .notmuch-config \ .ssh/authorized_keys \ @@ -25,6 +25,7 @@ EMPTYDIRS := \ $(patsubst services/available/%,.log/%,$(wildcard services/available/*)) \ Maildir \ .cache/mpd \ + .cache/notmuch \ .config/mpd/playlists INSTALL_CUSTOM := \ @@ -34,7 +35,8 @@ INSTALL_CUSTOM := \ BUILD := \ config/alacritty/alacritty.yml \ - mpdscribble/mpdscribble.conf + mpdscribble/mpdscribble.conf \ + mbsyncloop install :: @chmod 600 config/msmtp/config @@ -66,6 +68,9 @@ config/darksky : config/darksky/api : config/darksky rbw get darksky.net api > $@ +mbsyncloop: mbsyncrc + @sed 's/^PassCmd.*/PassCmd "head -n1 \/run\/user\/1000\/mbsyncloop"/' mbsyncrc > mbsyncloop + mpdscribble/mpdscribble.conf : mpdscribble/mpdscribble.conf.tmpl pass="$$(rbw get last.fm doyster)" &&\ perl -E'while (<STDIN>) { if (/^password =/) { say "password = $$ARGV[0]" } else { print } }' "$$pass" < $< > $@ diff --git a/bin/hornet/update-mail b/bin/hornet/update-mail deleted file mode 100755 index 8149a8d..0000000 --- a/bin/hornet/update-mail +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -set -eu -set -o pipefail - -stat=$(svstat "$HOME/.services/enabled/offlineimap") -if echo "$stat" | grep -q "offlineimap: down"; then - echo "no offlineimap process running" >&2 - exit 1 -fi -pid=$(echo "$stat" | sed 's/.*offlineimap: up (pid \([[:digit:]]\+\)).*/\1/') -kill -USR1 "$pid" diff --git a/bin/mbsyncloop b/bin/mbsyncloop new file mode 100755 index 0000000..3136c51 --- /dev/null +++ b/bin/mbsyncloop @@ -0,0 +1,42 @@ +#!/usr/bin/env perl +use 5.016; +use strict; +use warnings; + +use POSIX 'mkfifo'; + +my ($pw_pipe, $pid); + +sub cleanup { + unlink($pw_pipe) if $pw_pipe; + kill KILL => $pid if $pid; +} + +$SIG{INT} = $SIG{TERM} = sub { cleanup; exit }; +END { cleanup } + +$pw_pipe = "/run/user/$>/mbsyncloop"; +mkfifo($pw_pipe, 0700) or die "couldn't create $pw_pipe"; + +my $pw = `rbw get mail.tozt.net doy\@tozt.net`; + +$pid = fork; +die unless defined $pid; +if (!$pid) { + $SIG{PIPE} = sub {}; + while (1) { + open my $fh, '>', $pw_pipe or die "couldn't open $pw_pipe"; + $fh->print("$pw\n"); + close $fh; + } + exit; +} + +my $i = 0; +while (1) { + my $channel = $i % 15 ? "priority" : "all"; + system("mbsync -c ~/.mbsyncloop $channel") and last; + system("notmuch new") and last; + sleep 60; + $i++; +} diff --git a/config/offlineimap/config b/config/offlineimap/config deleted file mode 100644 index fd9110a..0000000 --- a/config/offlineimap/config +++ /dev/null @@ -1,34 +0,0 @@ -[general] -accounts = main -maxsyncaccounts = 3 -status_backend = sqlite -pythonfile = ~/.config/offlineimap/pass.py -ui = basic -socktimeout = 120 - -[Account main] -localrepository = main-local -remoterepository = main-remote -autorefresh = 5 -quick = 10 -postsynchook = notmuch new - -[Repository main-local] -type = Maildir -localfolders = ~/Maildir - -[Repository main-remote] -type = IMAP -ssl = yes -sslcacertfile = /etc/ssl/certs/ca-certificates.crt -remotehost = mail.tozt.net -remoteuser = doy@tozt.net -remotepasseval = get_password("mail.tozt.net", "doy@tozt.net") -maxconnections = 5 -keepalive = 60 -holdconnectionopen = yes -idlefolders = ['INBOX'] -folderfilter = lambda foldername: not re.search('^old(\.|$)', foldername) -subscribedonly = no - -# vim:ft=dosini: diff --git a/config/offlineimap/pass.py b/config/offlineimap/pass.py deleted file mode 100644 index 6a7fba3..0000000 --- a/config/offlineimap/pass.py +++ /dev/null @@ -1,5 +0,0 @@ -from subprocess import Popen, PIPE - -def get_password(name, user): - (out, err) = Popen(["rbw", "get", name, user], stdout=PIPE).communicate() - return out.strip() diff --git a/mbsyncrc b/mbsyncrc new file mode 100644 index 0000000..40080fb --- /dev/null +++ b/mbsyncrc @@ -0,0 +1,27 @@ +Expunge None +Create Both + +MaildirStore local +Path ~/Maildir/ +Inbox ~/Maildir/INBOX +Trash Trash +Flatten . + +IMAPStore mail +Host mail.tozt.net +User doy@tozt.net +PassCmd "rbw get mail.tozt.net doy@tozt.net" +SSLType IMAPS +SSLVersions TLSv1.2 TLSv1.3 + +Channel all +Far :mail: +Near :local: +Sync PullNew Push +Patterns * !.notmuch + +Channel priority +Far :mail: +Near :local: +Sync PullNew Push +Patterns INBOX personal diff --git a/mutt/choose-muttrc-type b/mutt/choose-muttrc-type index 21db151..363a64c 100755 --- a/mutt/choose-muttrc-type +++ b/mutt/choose-muttrc-type @@ -4,7 +4,7 @@ set -o pipefail case "$(hostname)" in hornet) - echo 'source ~/.mutt/offlineimap' + echo 'source ~/.mutt/local' ;; *) echo 'source ~/.mutt/imap' diff --git a/mutt/offlineimap b/mutt/local index e22fe53..0d6205f 100644 --- a/mutt/offlineimap +++ b/mutt/local @@ -10,7 +10,7 @@ mailboxes `\ echo -n "\"=$basename\" ";\ fi\ done` -macro index R "<enter-command>unset wait_key<enter><shell-escape>update-mail<enter><enter-command>set wait_key<enter>" "fetch mail with offlineimap" +macro index R "<enter-command>unset wait_key<enter><shell-escape>mbsync all && notmuch new<enter><enter-command>set wait_key<enter>" "fetch mail with mbsync" set timeout=3 # vim: ft=neomuttrc diff --git a/notmuch-config b/notmuch-config index 9b4117a..675036c 100644 --- a/notmuch-config +++ b/notmuch-config @@ -1,5 +1,6 @@ [database] -path=/home/doy/Maildir +path=/home/doy/.cache/notmuch +mail_root=/home/doy/Maildir [user] name=Jesse Luehrs diff --git a/services/available/mbsyncloop/log/run b/services/available/mbsyncloop/log/run new file mode 100755 index 0000000..5930eda --- /dev/null +++ b/services/available/mbsyncloop/log/run @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec multilog t s16777215 "$HOME/.log/mbsyncloop" diff --git a/services/available/mbsyncloop/run b/services/available/mbsyncloop/run new file mode 100755 index 0000000..ac7e636 --- /dev/null +++ b/services/available/mbsyncloop/run @@ -0,0 +1,3 @@ +#!/bin/sh + +exec mbsyncloop 2>&1 diff --git a/services/available/offlineimap/log/run b/services/available/offlineimap/log/run deleted file mode 100755 index 9883599..0000000 --- a/services/available/offlineimap/log/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -eu - -exec multilog t s16777215 "$HOME/.log/offlineimap" diff --git a/services/available/offlineimap/run b/services/available/offlineimap/run deleted file mode 100755 index 5589a60..0000000 --- a/services/available/offlineimap/run +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec offlineimap 2>&1 |