summaryrefslogtreecommitdiff
path: root/ar
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
parentfdc9dd9666dbf630b6d432dc20a56298779cde32 (diff)
modified cron/newsup, modified statusbar/sb-news
Diffstat (limited to 'ar')
-rwxr-xr-xar/.local/bin/cron/newsup8
-rwxr-xr-xar/.local/bin/statusbar/sb-news21
2 files changed, 27 insertions, 2 deletions
diff --git a/ar/.local/bin/cron/newsup b/ar/.local/bin/cron/newsup
index 4d387eb..f8e3181 100755
--- a/ar/.local/bin/cron/newsup
+++ b/ar/.local/bin/cron/newsup
@@ -3,9 +3,15 @@
# Set as a cron job to check for new RSS entries for newsboat.
# If newsboat is open, sends it an "R" key to refresh.
+# Bail if a previous run is still going. With the fulltext filter a reload now
+# takes ~17s+, so back-to-back cron ticks could overlap: a second `-x reload`
+# can't grab the cache.db lock, and the rm/signal races blank the status bar.
+exec 9>/tmp/newsup.lock
+flock -n 9 || exit
+
/usr/bin/notify-send "📰 Updating RSS feeds..."
-pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit
+pgrep -x newsboat && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit
echo "📰$(/usr/bin/newsboat -x print-unread | awk '{print $1}')🔃" >/tmp/newsupdate
pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}"
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