aboutsummaryrefslogtreecommitdiff
path: root/env/.local/bin/system/start-scripts/newsboat-fetch.sh
blob: bd9146c8fa71266ed804536a2a9f0ee589595e8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

CACHE_FILE="/tmp/newsboat-unreads.cache"

[ -f "$CACHE_FILE" ] || echo "0" > "$CACHE_FILE"

newsboat_loop(){
    NO_PROXY=\".com,.org,.xyz,.chat,.social,.net,.co,.love\" newsboat -x reload

    unreads=$(newsboat -x print-unread)
    unreadnum=$(printf -- "%s" "$unreads" | sed 's/ .*//g')

    echo "${unreadnum:-0}" > "$CACHE_FILE"

    if [ "$unreadnum" -gt 0 ]; then
        notify-send "newsboat feed" "$unreads"
    fi
    notify-send "Vitamins!" "take them"
    sleep 2h
    newsboat_loop
}
newsboat_loop