display all new articles, not just last one (but do not renotify)

This commit is contained in:
Alexander Bocken 2021-05-12 00:08:52 +02:00
parent 452fc356d0
commit 195a5ec9b6
Signed by: Alexander
GPG Key ID: 1D237BE83F9B05E8

View File

@ -1,7 +1,13 @@
#!/bin/sh #!/bin/sh
CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/cache.db" CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/cache.db"
unread="$(sqlite3 "$CACHE" "SELECT unread,pubDate,title FROM rss_item;" | ALREADY_NOTIFIED="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/notified"
grep -vE '^0' | sort -t'|' -k2 -gr | head -n1 | [ -f "$ALREADY_NOTIFIED" ] || touch "$ALREADY_NOTIFIED"
sed 's/[0-9]*|[0-9]*|//')"
notify-send "newsboat" "$(printf 'new article:\n %s' "$unread")" unread="$(sqlite3 "$CACHE" "SELECT unread,pubDate,title FROM rss_item;" |
grep -vE '^0' | sort -t'|' -k2 -gr |
grep -vf "$ALREADY_NOTIFIED")"
echo "$unread" >> "$ALREADY_NOTIFIED"
[ "$( echo "$unread" | wc -l)" -gt 1 ] && plural=s
formatted="$(echo "$unread" | sed 's/[0-9]*|[0-9]*|//')"
notify-send "newsboat" "$(printf 'new article%s:\n %s' "$plural" "$formatted")"