From 978ec811803cdbeb10dc2e6924ab33aa2b84bec6 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 11 Nov 2026 09:53:37 +0100 Subject: feat(dashboard): pending updates in the system row, icons, opencode logo The system row now ends with "N updates available", keystone's "to install" count from updatesctl ([dashboard] updates; empty hides it). stats re-reads it in a thread every 5 minutes, so the NFS reads behind it never stall the 1 s poll. The codename reads "-current" next to the OS name, so it no longer looks like part of the kernel. Kernel and uptime get tux and clock icons, the row is tighter, and its separators are a "|" in the first Hyprland border colour instead of an unreadable dot. The opencode spending card shows the opencode logo by its title. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 3 +++ config.toml | 3 +++ deckit/modules/stats.py | 29 ++++++++++++++++++++++++++++- static/dashboard.js | 25 ++++++++++++++++--------- static/deck.css | 9 +++++---- tests/test_stats.py | 5 +++++ 6 files changed, 60 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 498d1ce..7db00b7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,6 +29,9 @@ Keep the server dependency-free apart from that one package. slot builds its markup once and then only sets text, so its scrolling lines are not restarted. Hyprland's border colours (`--udt-border-1..3`) colour the trend lines and progress bars and rotate around the action icons. +- `stats` also carries `updates`, keystone's "to install" count from + `updatesctl` (`[dashboard] updates`, empty hides it), re-read in a thread + every 5 min so its NFS reads never stall the 1s poll. - `actions` serves the Dashboard's icons: `[dashboard] actions`, ids from `config.ACTION_IDS`, each a fixed command (`screenshot` runs `qar-scrotmenu.sh`, `lock` runs `lock.sh`). Its watcher checks `pidof diff --git a/config.toml b/config.toml index b65caab..e5bc329 100644 --- a/config.toml +++ b/config.toml @@ -107,3 +107,6 @@ apps = ["kitty", "pcmanfm-qt", "com.obsproject.Studio", "firefox", "signal-deskt # Icon buttons at the bottom of the Dashboard, in order. Each id runs a fixed # command on the PC: screenshot opens qar-scrotmenu.sh, lock runs lock.sh. actions = ["screenshot", "lock"] +# keystone's updatesctl; its "to install" count shows in the system row. +# Empty hides it. +updates = "~/Programming/GIT/quickshell/desktop/modules/updates/updatesctl" diff --git a/deckit/modules/stats.py b/deckit/modules/stats.py index a60605e..947b334 100644 --- a/deckit/modules/stats.py +++ b/deckit/modules/stats.py @@ -14,17 +14,20 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -"""System stats: CPU, memory, GPU (Intel xe), network, uptime. +"""System stats: CPU, memory, GPU (Intel xe), network, uptime, pending updates. The Arc driver exposes temperature and fan through hwmon and no VRAM capacity; VRAM in use comes from the DRM fdinfo scan, as quickshell's perf panel does. """ +import json +import os import platform import re import shlex import socket import subprocess +import threading import time from pathlib import Path @@ -148,8 +151,31 @@ def _net_iface(hw): return None +def _to_install(doc): + """updatesctl's JSON -> what keystone's tile counts "to install".""" + sw = doc.get("slackware", {}) + return sum(len(sw.get(k, [])) for k in ("upgrade", "new", "removed")) + len(doc.get("upgrade", [])) + + def make(cfg: dict) -> Module: hw = cfg.get("hardware", {}) + updatesctl = os.path.expanduser(cfg.get("dashboard", {}).get("updates", "")) + upd = {"n": None, "t": 0, "busy": False} + + def read_updates(): + try: + out = subprocess.run([updatesctl], capture_output=True, text=True, timeout=30).stdout + upd["n"] = _to_install(json.loads(out)) + except (OSError, subprocess.TimeoutExpired, ValueError): + pass + upd.update(t=time.monotonic(), busy=False) + + def updates(): + # ponytail: re-read every 5 min in a thread, so the NAS reads never stall the 1 s poll + if updatesctl and not upd["busy"] and (not upd["t"] or time.monotonic() - upd["t"] > 300): + upd["busy"] = True + threading.Thread(target=read_updates, daemon=True).start() + return upd["n"] cpu_sensor = _cpu_sensor(hw) battery = _battery(hw) gpu = _gpu(hw) @@ -218,6 +244,7 @@ def make(cfg: dict) -> Module: "battery": {"level": int(_read(battery / "capacity", "0")), "status": _read(battery / "status")} if battery else None, "net": {"down": down, "up": up}, + "updates": updates(), } return Module(name="stats", title="System", state=state) diff --git a/static/dashboard.js b/static/dashboard.js index 390c802..21e1cf3 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -24,7 +24,7 @@ export const HISTORY = 120; // trend samples: two minutes at 1 s const RUNNING = ["k1c", "sbbuilder", "obs"]; // the running row's order const G = { cpu: "", mem: "\u{f035b}", gpu: "\u{f08ae}", net: "\u{f04e1}", - wifi: "", charging: "\u{f0084}", tux: "" }; + wifi: "", charging: "\u{f0084}", tux: "", clock: "" }; const BATTERY = ["", "", "", "", ""]; // Nerd Font distro logos by os-release ID. const DISTRO = { @@ -109,8 +109,10 @@ const SKELETON = `
-
- ·
+
+ |${G.tux} + |${G.clock} + |
${G.cpu}
@@ -164,8 +166,12 @@ export default { if (on.has("stats")) poll("stats", 1, (st) => { $(".logo").textContent = DISTRO[st.os?.id] ?? G.tux; $(".os").textContent = st.os?.name ?? ""; - $(".kernel").textContent = [st.os?.codename, `Linux ${st.os?.kernel ?? ""}`].filter(Boolean).join(" · "); - $(".up").textContent = `up ${uptime(st.uptime)}`; + $(".codename").textContent = st.os?.codename ? `-${st.os.codename}` : ""; + $(".codename").hidden = !st.os?.codename; + $(".kernel").textContent = st.os?.kernel ?? ""; + $(".up").textContent = uptime(st.uptime); + for (const e of root.querySelectorAll(".upd")) e.hidden = st.updates == null; + $(".n-upd").textContent = `${st.updates} update${st.updates === 1 ? "" : "s"} available`; push(hist.cpu, st.cpu); push(hist.down, st.net.down); push(hist.up, st.net.up); $(".c-cpu .n").textContent = st.cpuName ?? ""; $(".c-cpu path").setAttribute("d", area(hist.cpu, Math.max(25, ...hist.cpu))); @@ -187,17 +193,18 @@ export default { chip(".c-net", `↓${rate(st.net.down)} ↑${rate(st.net.up)}`); }); - const program = (title, p) => { + const program = (title, p, brand) => { + const h3 = `

${brand ? `` : ""}${esc(title)}

`; const model = `${esc(p.model ? short(p.model) : "—")}`; if (!(p.cost > 0)) { // local or free models: tokens, not dollars - return `

${esc(title)}

${model} + return `
${h3}${model} session${tok(p.session_tokens)} total${tok(p.tokens)}
`; } const parts = spendParts(p.models); const total = parts.reduce((a, m) => a + m.cost, 0); const color = (m, i) => (m.model === "other" ? OTHER : SPEND[i]); - return `

${esc(title)}

${model}
+ return `
${h3}${model}
session
${money(p.session_cost)}
${tok(p.session_tokens)} · ${p.session_calls ?? 0} calls
@@ -223,7 +230,7 @@ export default { chip(".c-5h", pct(c.five_hour_pct), null, c.five_hour_pct, c.five_hour_pct >= 80); chip(".c-7d", pct(c.seven_day_pct), null, c.seven_day_pct, c.seven_day_pct >= 80); spend._offline = null; - spend.innerHTML = program("opencode", st.opencode ?? {}) + program("Local Agent", st.assistant ?? {}); + spend.innerHTML = program("opencode", st.opencode ?? {}, "opencode") + program("Local Agent", st.assistant ?? {}); }); if (on.has("tablet")) poll("tablet", 10, (t) => { diff --git a/static/deck.css b/static/deck.css index 1d02a85..35c6335 100644 --- a/static/deck.css +++ b/static/deck.css @@ -646,10 +646,11 @@ select { .dash-defs { position: absolute; } .dash-top { display: grid; grid-template-rows: auto 1fr 1fr; gap: 8px; min-height: 0; } -.dash-id { display: flex; align-items: center; gap: 14px; font-size: 0.857rem; color: var(--udt-subtext0); white-space: nowrap; overflow: hidden; } -.dash-id .logo { font-size: 1.15rem; color: var(--udt-accent); } +.dash-id { display: flex; align-items: center; gap: 8px; font-size: 0.857rem; color: var(--udt-subtext0); white-space: nowrap; overflow: hidden; } +.dash-id .logo { font-size: 1.15rem; color: var(--udt-accent); margin-right: 4px; } +.dash-id .nf:not(.logo) { margin-right: 10px; } /* the glyphs draw past their advance */ .dash-id b { color: var(--udt-text); font-weight: 600; } -.dash-id .sep { color: var(--udt-surface2); } +.dash-id .sep { color: var(--udt-border-1); font-weight: 600; } .dash .chips { display: grid; gap: 8px; min-height: 0; } .dash .chips.sys { grid-template-columns: 1fr 1fr 1fr 1.3fr; } .dash .chips.aux { grid-template-columns: 1fr 1fr 1fr 1fr 1.3fr; } @@ -687,7 +688,7 @@ select { .dash .prog { display: flex; flex-direction: column; gap: 6px; } .dash .prog header { display: flex; align-items: baseline; gap: 10px; } -.dash .prog h3 { margin: 0; font-size: 0.857rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-subtext0); } +.dash .prog h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.857rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-subtext0); } .dash .prog .model { margin-left: auto; font-size: 0.786rem; color: var(--udt-overlay0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .dash .prog .nums { display: flex; gap: 22px; align-items: baseline; } .dash .prog .big { font-size: 1.25rem; font-weight: 600; } diff --git a/tests/test_stats.py b/tests/test_stats.py index f732054..f45a0cd 100644 --- a/tests/test_stats.py +++ b/tests/test_stats.py @@ -31,6 +31,11 @@ class Stats(unittest.TestCase): self.assertIn(key, st) self.assertIsInstance(st["cpu"], int) + def test_to_install_counts_like_keystone(self): + doc = {"slackware": {"upgrade": [1, 2], "new": [3], "removed": [4]}, + "upgrade": [5], "build": [6, 7], "upstream": [8], "apps": [9]} + self.assertEqual(stats._to_install(doc), 5) + def test_build_discovers_stats(self): from deckit.modules import build names = [m["name"] for m in build({"modules": {}}).names()] -- cgit v1.2.3