configuration/services/sfeed/run

31 lines
685 B
Plaintext
Raw Normal View History

#!/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)"
trap "rm -rf '$d'" EXIT KILL
mmkdir "$d"
sfeed_update > /dev/null 2>&1 || true
sfeed_mbox ~/.sfeed/feeds/* | mdeliver -M -v "$d" | while read mail; do
if mlist /data/mail/feeds | magrep -q message-id:"$(mshow -qh message-id "$mail" | cut -d' ' -f2)"; then
continue
fi
if rg -qF "$(mshow -O "$mail" 1)" /data/mail/feeds; then
continue
fi
mdeliver /data/mail/feeds < "$mail" > /dev/null
done
rm -rf "$d"
exec sleep 1h