2021-03-16 12:10:07 +01:00
|
|
|
#!/bin/sh
|
|
|
|
export USER="$(whoami)"
|
|
|
|
export HOME=/home/"$USER"
|
|
|
|
export DISPLAY=":0"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# check for internet connection
|
|
|
|
ip route ls | grep -q '.'
|
|
|
|
|
|
|
|
# check if the gpg-agent is running
|
|
|
|
pgrep gpg-agent > /dev/null
|
|
|
|
|
|
|
|
# Find new messages in feeds
|
|
|
|
d="$(mktemp -d)"
|
2021-03-17 09:59:47 +01:00
|
|
|
trap "rm -rf '$d'" EXIT KILL
|
2021-03-16 12:10:07 +01:00
|
|
|
mmkdir "$d"
|
2022-09-24 10:52:46 +02:00
|
|
|
sfeed_update > /dev/null 2>&1 || true
|
2021-03-16 12:10:07 +01:00
|
|
|
sfeed_mbox ~/.sfeed/feeds/* | mdeliver -M -v "$d" | while read mail; do
|
2022-09-24 10:52:46 +02:00
|
|
|
if mlist /data/mail/feeds | magrep -q message-id:"$(mshow -qh message-id "$mail" | cut -d' ' -f2)"; then
|
|
|
|
continue
|
2021-03-16 12:10:07 +01:00
|
|
|
fi
|
2022-09-24 10:52:46 +02:00
|
|
|
if rg -qF "$(mshow -O "$mail" 1)" /data/mail/feeds; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
mdeliver /data/mail/feeds < "$mail" > /dev/null
|
2021-03-16 12:10:07 +01:00
|
|
|
done
|
|
|
|
rm -rf "$d"
|
|
|
|
|
|
|
|
exec sleep 1h
|