From 195a5ec9b6346369136db98f2fe306cb723e5ece Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Wed, 12 May 2021 00:08:52 +0200 Subject: [PATCH] display all new articles, not just last one (but do not renotify) --- .local/bin/newsboatnotifs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.local/bin/newsboatnotifs b/.local/bin/newsboatnotifs index 1077eb8..4278c49 100755 --- a/.local/bin/newsboatnotifs +++ b/.local/bin/newsboatnotifs @@ -1,7 +1,13 @@ #!/bin/sh CACHE="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/cache.db" -unread="$(sqlite3 "$CACHE" "SELECT unread,pubDate,title FROM rss_item;" | - grep -vE '^0' | sort -t'|' -k2 -gr | head -n1 | - sed 's/[0-9]*|[0-9]*|//')" +ALREADY_NOTIFIED="${XDG_DATA_HOME:-$HOME/.local/share}/newsboat/notified" +[ -f "$ALREADY_NOTIFIED" ] || touch "$ALREADY_NOTIFIED" -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")"