From e55896ce41d6165105671da5b6f33813106ef1b8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 30 Sep 2026 19:56:47 +0200 Subject: feat: add an updates card showing nvtable's package table Moves the nvchecker/nvtable table the login shell printed onto the dashboard, as a wide card at the bottom centre. bin/updates-sample.sh caches `nvtable -C -E` every ten minutes and starts nvchecker, fully detached, at most every 30 minutes. The widget parses the cache and colours it in the board's language: installed behind upstream is critical, a shipped .info behind is a warning, with nvtable's status dots per row and a legend on the bottom line. The mouse wheel scrolls rows that do not fit. Co-Authored-By: Claude Opus 5.5 --- bin/updates-sample.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 bin/updates-sample.sh (limited to 'bin/updates-sample.sh') diff --git a/bin/updates-sample.sh b/bin/updates-sample.sh new file mode 100755 index 0000000..0c9ee3a --- /dev/null +++ b/bin/updates-sample.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Sample nvtable's package-update table into a cache file, for +# widgets/updates.lua. Replaces the table the login shell used to print. +# +# nvchecker itself is slow (one network request per stanza), so it is started +# in the background at most every 30 minutes, fully detached: conky's execi +# waits for stdout to close, and a child holding it would stall the dashboard. +# nvtable then reads whatever results the last completed run left, so a fresh +# nvchecker run shows up on the next sample. + +set -u + +CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/udt" +CACHE="$CACHE_DIR/updates.txt" +STAMP="$CACHE_DIR/nvchecker.stamp" +NVCHECK_EVERY=1800 + +# conky launched from the compositor does not inherit the login shell's PATH. +PATH="$HOME/bin:$HOME/.local/bin:$PATH" + +command -v nvtable >/dev/null || { echo "updates-sample: nvtable not found" >&2; exit 1; } + +mkdir -p "$CACHE_DIR" + +if command -v nvchecker >/dev/null; then + last=$(cat "$STAMP" 2>/dev/null || echo 0) + now=$(date +%s) + if (( now - ${last:-0} >= NVCHECK_EVERY )); then + echo "$now" > "$STAMP" + setsid nvchecker /dev/null 2>&1 & + fi +fi + +TMP="$CACHE.tmp.$$" +trap 'rm -f "$TMP"' EXIT + +# -C and -E: plain ASCII, which the widget parses and colours itself. +# Keep the old cache when nvtable fails, rather than replacing it with nothing. +nvtable -C -E > "$TMP" 2>/dev/null && mv -f "$TMP" "$CACHE" -- cgit v1.2.3