From 624a7a845c601990f5550a3cb3db38b139feb5da Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 10 Nov 2026 18:20:15 +0100 Subject: feat(stats): processor and card names, both network rates large The CPU tile is labelled with /proc/cpuinfo's model name, trimmed of core counts and trademarks; the GPU tile with lspci's marketing name for the xe card. The network tile shows download and upload side by side at the same size. Co-Authored-By: Claude Opus 5.5 --- deckit/modules/stats.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'deckit') diff --git a/deckit/modules/stats.py b/deckit/modules/stats.py index c190ec8..a764246 100644 --- a/deckit/modules/stats.py +++ b/deckit/modules/stats.py @@ -21,7 +21,9 @@ VRAM in use comes from the DRM fdinfo scan, as quickshell's perf panel does. """ import re +import shlex import socket +import subprocess import time from pathlib import Path @@ -89,12 +91,40 @@ def _battery(hw): return None +def _cpu_name(cpuinfo): + """'AMD Ryzen 7 9700X 8-Core Processor' -> 'AMD Ryzen 7 9700X'.""" + for line in cpuinfo.splitlines(): + if line.startswith("model name"): + name = re.sub(r"\((R|TM)\)|\bCPU\b|@.*|\d+-Core|Processor", "", line.partition(":")[2]) + return " ".join(name.split()) or None + return None + + +def _gpu_name(lspci): + """lspci -mm's line -> 'Intel Arc B580': the vendor's first word, then the + marketing name in brackets, else the whole device name.""" + try: + f = shlex.split(lspci) + except ValueError: + return None + if len(f) < 4: + return None + m = re.search(r"\[(.+?)\]", f[3]) + return f"{f[2].split()[0]} {m[1] if m else f[3]}" + + def _gpu(hw): if hw.get("gpu", "auto") == "none": return None for name in Path("/sys/class/hwmon").glob("hwmon*/name"): if _read(name) == "xe": - return {"hwmon": name.parent, "name": "Intel Arc"} + slot = (name.parent / "device").resolve().name + try: + out = subprocess.run(["lspci", "-mm", "-s", slot], capture_output=True, + text=True, timeout=2).stdout + except (OSError, subprocess.TimeoutExpired): + out = "" + return {"hwmon": name.parent, "name": _gpu_name(out) or "GPU"} return None @@ -113,6 +143,7 @@ def make(cfg: dict) -> Module: cpu_sensor = _cpu_sensor(hw) battery = _battery(hw) gpu = _gpu(hw) + cpu_name = _cpu_name(_read("/proc/cpuinfo")) or "CPU" gpu_total = _parse_bytes(hw.get("gpu_mem_total", "")) if gpu else None prev = {"cpu": None, "net": None, "t": None, "gpu_t": 0, "gpu_v": None} @@ -167,6 +198,7 @@ def make(cfg: dict) -> Module: "host": socket.gethostname(), "uptime": int(float(_read("/proc/uptime", "0").split()[0])), "cpu": cpu_percent(), + "cpuName": cpu_name, "cpuTemp": round(int(t) / 1000) if t else None, "memUsed": mem["MemTotal"] - mem["MemAvailable"], "memTotal": mem["MemTotal"], -- cgit v1.2.3