diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-11 09:53:37 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-11 09:53:37 +0100 |
| commit | 978ec811803cdbeb10dc2e6924ab33aa2b84bec6 (patch) | |
| tree | a9c217da32594492f43be941fca139d7950d7cbd /deckit | |
| parent | 085eaa7d3876fa0c9f5d5390bfe2395b85e46b62 (diff) | |
| download | deck-it-978ec811803cdbeb10dc2e6924ab33aa2b84bec6.tar.gz deck-it-978ec811803cdbeb10dc2e6924ab33aa2b84bec6.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'deckit')
| -rw-r--r-- | deckit/modules/stats.py | 29 |
1 files changed, 28 insertions, 1 deletions
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) |
