aboutsummaryrefslogtreecommitdiffstats
path: root/deckit
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 18:23:20 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 18:23:20 +0100
commit5b85512ccd0d87cb61c30f73cea262c7a0545d37 (patch)
treeb186fd0b5f1fad48c5b0be6b78da3661ea6aa8c8 /deckit
parent624a7a845c601990f5550a3cb3db38b139feb5da (diff)
downloaddeck-it-5b85512ccd0d87cb61c30f73cea262c7a0545d37.tar.gz
deck-it-5b85512ccd0d87cb61c30f73cea262c7a0545d37.zip
feat(stats): an OS row with logo, kernel and uptime
The System card's small 'up Nh' line becomes a full-width tile: the distro's Nerd Font logo, NAME and VERSION_ID from /etc/os-release in large type, the codename and kernel release below, and the uptime large on the right. An unknown distro gets Tux. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'deckit')
-rw-r--r--deckit/modules/stats.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/deckit/modules/stats.py b/deckit/modules/stats.py
index a764246..a60605e 100644
--- a/deckit/modules/stats.py
+++ b/deckit/modules/stats.py
@@ -20,6 +20,7 @@ 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 platform
import re
import shlex
import socket
@@ -100,6 +101,15 @@ def _cpu_name(cpuinfo):
return None
+def _os(text):
+ """/etc/os-release -> {"id", "name", "codename"}."""
+ f = {k: v.strip().strip('"') for k, _, v in
+ (line.partition("=") for line in text.splitlines()) if v}
+ name = " ".join(filter(None, (f.get("NAME"), f.get("VERSION_ID"))))
+ return {"id": f.get("ID", "linux"), "name": name or "Linux",
+ "codename": f.get("VERSION_CODENAME", "")}
+
+
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."""
@@ -144,6 +154,7 @@ def make(cfg: dict) -> Module:
battery = _battery(hw)
gpu = _gpu(hw)
cpu_name = _cpu_name(_read("/proc/cpuinfo")) or "CPU"
+ os_info = {**_os(_read("/etc/os-release")), "kernel": platform.release()}
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}
@@ -196,6 +207,7 @@ def make(cfg: dict) -> Module:
t = _read(cpu_sensor) if cpu_sensor else ""
return {
"host": socket.gethostname(),
+ "os": os_info,
"uptime": int(float(_read("/proc/uptime", "0").split()[0])),
"cpu": cpu_percent(),
"cpuName": cpu_name,