summaryrefslogtreecommitdiff
path: root/ar/.local/bin/statusbar/sb-news
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-06-16 15:44:33 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-06-16 15:44:33 +0900
commitaa434f25381ae6236afd3273df8238eadc80b32b (patch)
treea88e61a19fb9f2b695569feab98dae57e4bbdeff /ar/.local/bin/statusbar/sb-news
parentfdc9dd9666dbf630b6d432dc20a56298779cde32 (diff)
modified cron/newsup, modified statusbar/sb-news
Diffstat (limited to 'ar/.local/bin/statusbar/sb-news')
-rwxr-xr-xar/.local/bin/statusbar/sb-news21
1 files changed, 20 insertions, 1 deletions
diff --git a/ar/.local/bin/statusbar/sb-news b/ar/.local/bin/statusbar/sb-news
index 920f818..8f4d7ad 100755
--- a/ar/.local/bin/statusbar/sb-news
+++ b/ar/.local/bin/statusbar/sb-news
@@ -14,4 +14,23 @@ case $BLOCK_BUTTON in
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
-cat /tmp/newsupdate 2>/dev/null || echo "$(newsboat -x print-unread | awk '{ if($1>0) print "📰" $1}')$(cat "${XDG_CONFIG_HOME:-${HOME}/.config}"/newsboat/.update 2>/dev/null)"
+# During a sync, `newsup` writes the spinner to /tmp/newsupdate; show that.
+# Otherwise read the unread count. `newsboat -x print-unread` needs the cache.db
+# lock and prints NOTHING (exit 1, "an instance is already running") whenever
+# another newsboat holds it — e.g. a slow `-x reload`. Falling through to an
+# empty block makes the icon vanish/flicker, so cache the last good count and
+# reuse it when the read fails.
+if [ -f /tmp/newsupdate ]; then
+ cat /tmp/newsupdate
+else
+ cache="${XDG_CACHE_HOME:-${HOME}/.cache}/newsunread"
+ count=$(newsboat -x print-unread 2>/dev/null | awk '{print $1}')
+ if [ -n "$count" ]; then
+ printf '%s' "$count" >"$cache"
+ else
+ count=$(cat "$cache" 2>/dev/null) # DB locked → reuse last known value
+ fi
+ [ "${count:-0}" -gt 0 ] 2>/dev/null && printf '📰%s' "$count"
+ cat "${XDG_CONFIG_HOME:-${HOME}/.config}"/newsboat/.update 2>/dev/null
+ echo
+fi