summaryrefslogtreecommitdiff
path: root/ar/.local
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-06-16 19:12:52 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-06-16 19:12:52 +0900
commitabf5e628280fa602a3650542bc13d28836e34cd3 (patch)
treebfbba90e8067a0c83cd7a1392ef469250aeb5966 /ar/.local
parent7a3683c4fa07ca83a3d13edb97d6cd2fff47ffa1 (diff)
modified cron/newsup
Diffstat (limited to 'ar/.local')
-rwxr-xr-xar/.local/bin/cron/newsup19
1 files changed, 19 insertions, 0 deletions
diff --git a/ar/.local/bin/cron/newsup b/ar/.local/bin/cron/newsup
index f8e3181..7987f0b 100755
--- a/ar/.local/bin/cron/newsup
+++ b/ar/.local/bin/cron/newsup
@@ -16,6 +16,25 @@ pgrep -x newsboat && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --
echo "📰$(/usr/bin/newsboat -x print-unread | awk '{print $1}')🔃" >/tmp/newsupdate
pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}"
/usr/bin/newsboat -x reload
+
+# Prune feeds no longer in the urls file. Editing urls directly (removing or
+# changing a feed) leaves the old feed's items in cache.db; newsboat hides them
+# (not in urls) but sb-news counts every unread row, so they show as a phantom
+# count. cleanup-on-quit only fires on a graceful `q` quit, so we replicate it
+# here non-interactively: any rss_feed.rssurl not present in urls is an orphan.
+# Safe to write directly — newsboat isn't running in this branch (it exits at
+# the xdotool line above) and `-x reload` has already released the cache lock.
+nb_db="${XDG_DATA_HOME:-${HOME}/.local/share}/newsboat/cache.db"
+nb_urls="${XDG_CONFIG_HOME:-${HOME}/.config}/newsboat/urls"
+awk '!/^[[:space:]]*#/ && ($1 ~ /^https?:/ || $1 ~ /^filter:/){print $1}' "$nb_urls" \
+ | sort -u >/tmp/newsup_urls.$$
+/usr/bin/sqlite3 "$nb_db" "SELECT rssurl FROM rss_feed;" | sort -u \
+ | comm -23 - /tmp/newsup_urls.$$ | while IFS= read -r u; do
+ [ -n "$u" ] && /usr/bin/sqlite3 "$nb_db" \
+ "DELETE FROM rss_item WHERE feedurl='$u'; DELETE FROM rss_feed WHERE rssurl='$u';"
+ done
+rm -f /tmp/newsup_urls.$$
+
rm -f /tmp/newsupdate
pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}"
/usr/bin/notify-send "📰 RSS feed update complete."