aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2023-09-28 17:59:47 -0500
committerToby Vincent <tobyv@tobyvin.dev>2023-09-28 17:59:47 -0500
commita764a9ee86d47f54825a086db1cc2def8196c593 (patch)
tree969d6b6f2be72ff0d642f8fb342935cc45b444e9
parent3b16b85d5e8a1c55449ecbde6a42eac3e6a8af0a (diff)
fix(mbsync): split notify service by maildir
-rw-r--r--mbsync/.config/systemd/user/maildir-notify.service10
-rw-r--r--mbsync/.config/systemd/user/maildir-notify@.service10
-rwxr-xr-xmbsync/.local/bin/maildir-notify27
-rwxr-xr-xmbsync/install.sh27
-rw-r--r--r2e/.config/rss2email.cfg3
5 files changed, 50 insertions, 27 deletions
diff --git a/mbsync/.config/systemd/user/maildir-notify.service b/mbsync/.config/systemd/user/maildir-notify.service
deleted file mode 100644
index 3c57b06..0000000
--- a/mbsync/.config/systemd/user/maildir-notify.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Watches Maildir for new mail and sends notifications
-
-[Service]
-Type=simple
-ExecStart=%h/.local/bin/maildir-notify
-RestartSec=10
-
-[Install]
-WantedBy=default.target
diff --git a/mbsync/.config/systemd/user/maildir-notify@.service b/mbsync/.config/systemd/user/maildir-notify@.service
new file mode 100644
index 0000000..6d2d3e0
--- /dev/null
+++ b/mbsync/.config/systemd/user/maildir-notify@.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Notify on new mail in MailDir %i
+
+[Service]
+Type=simple
+ExecStart=%h/.local/bin/maildir-notify ${XDG_DATA_HOME}/mail/%i/INBOX
+RestartSec=10
+
+[Install]
+WantedBy=default.target
diff --git a/mbsync/.local/bin/maildir-notify b/mbsync/.local/bin/maildir-notify
index 065339f..61fc434 100755
--- a/mbsync/.local/bin/maildir-notify
+++ b/mbsync/.local/bin/maildir-notify
@@ -1,31 +1,24 @@
#!/bin/sh
-if [ $# = 0 ]; then
- for d in "$XDG_DATA_HOME"/mail/*; do
- set -- "$@" "${d}/INBOX"
- done
-fi
-
-for i; do
- set -- "$@" "${i}/new"
+for maildir; do
+ echo "Monitoring $maildir"
+ set -- "$@" "${maildir}/new"
shift
done
-echo "Watching $*"
-
inotifywait --monitor --event create --event moved_to "$@" |
while read -r dir _action file; do
- inbox="$(dirname "$dir")"
- category="$(dirname "$inbox" | xargs basename)"
+ maildir="$(dirname "$dir")"
+ category="$(dirname "$maildir" | xargs basename)"
from="$(grep -m1 -oP '(?<=^From: ).*' "${dir}${file}")"
subject="$(grep -m1 -oP '(?<=^Subject: ).*' "${dir}${file}")"
- if [ ! -e "$inbox/new/$file" ]; then
- if [ -e "$inbox/cur/$file" ]; then
- from="$(grep -m1 -oP '(?<=^From: ).*' "$inbox/cur/$file")"
- subject="$(grep -m1 -oP '(?<=^Subject: ).*' "$inbox/cur/$file")"
+ if [ ! -e "$maildir/new/$file" ]; then
+ if [ -e "$maildir/cur/$file" ]; then
+ from="$(grep -m1 -oP '(?<=^From: ).*' "$maildir/cur/$file")"
+ subject="$(grep -m1 -oP '(?<=^Subject: ).*' "$maildir/cur/$file")"
else
- echo "Failed to read message. File: $file"
+ echo "Failed to read message. File: $file" 1>&2
continue
fi
fi
diff --git a/mbsync/install.sh b/mbsync/install.sh
new file mode 100755
index 0000000..dafb48e
--- /dev/null
+++ b/mbsync/install.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if command -v mbsync >/dev/null; then
+ systemctl --user enable --now mbsync.service
+else
+ cat <<-EOF
+ command not found: mbsync
+
+ install 'isync' package:
+ paru -S isync
+ EOF
+fi
+
+if command -v goimapnotify >/dev/null; then
+ systemctl --user enable --now goimapnotify@gmail.service
+ systemctl --user enable --now goimapnotify@porkbun.service
+else
+ cat <<-EOF
+ command not found: goimapnotify
+
+ install 'goimapnotify' package:
+ paru -S goimapnotify
+ EOF
+fi
+
+systemctl --user enable --now maildir-notify@gmail.service
+systemctl --user enable --now maildir-notify@porkbun.service
diff --git a/r2e/.config/rss2email.cfg b/r2e/.config/rss2email.cfg
index 1c63b3f..badee64 100644
--- a/r2e/.config/rss2email.cfg
+++ b/r2e/.config/rss2email.cfg
@@ -121,3 +121,6 @@ url = https://wayofthecrab.com/rss.xml
[feed.twim]
url = https://matrix.org/category/this-week-in-matrix/atom.xml
+[feed.fff]
+url = https://factorio.com/blog/rss
+