From e07291ee7c0c65f15d8e0d33dac25da8ef935659 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 30 Nov 2026 17:49:06 +0100 Subject: feat(network): speedtest with live progress, and section headers A Speedtest section runs ~/bin/speedtest (Ookla's CLI) with --format=jsonl. It streams one event per line, measured at 5 ping, 72 download and 104 upload events with `progress` (0..1) and a running `bandwidth` in bytes/s, then one result. The page shows the phase's progress bar, the live Mbit/s, and both curves on one scale, each stretched to the full width; the graph stays with the result. --accept-license and --accept-gdpr keep a first-run prompt from blocking it. The run and its state live in NetworkModule, which is always active, so a test survives the drawer closing and its result is there on reopen. An exit without a result reports "Speedtest failed (exit N)". The page's titles move to SectionHeader, with Speedtest given one. Co-Authored-By: Claude Opus 5.5 --- desktop/modules/network/NetworkModule.qml | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'desktop/modules/network/NetworkModule.qml') diff --git a/desktop/modules/network/NetworkModule.qml b/desktop/modules/network/NetworkModule.qml index 0310475..186d15b 100644 --- a/desktop/modules/network/NetworkModule.qml +++ b/desktop/modules/network/NetworkModule.qml @@ -104,6 +104,66 @@ Module { property Process notifyProc: Process {} + // Ookla's CLI, run on demand. It lives here rather than in the page so a + // test survives the drawer closing and its result is still there on + // reopen. --format=jsonl streams one event per line: testStart, then + // ping, download and upload events carrying `progress` (0..1) and the + // running `bandwidth` (bytes/s), then one result (measured: 5 ping, 72 + // download, 104 upload events on a gigabit line). + property var speedResult: null // {down, up, ping, server} or null + property string speedPhase: "" // ping | download | upload while running + property real speedProgress: 0 + property real speedLive: 0 // Mbit/s, the current phase's running figure + property var speedDown: [] // Mbit/s samples, for the page's graph + property var speedUp: [] + readonly property bool speedRunning: speedProc.running + function runSpeedtest() { + mod.speedResult = null; + mod.speedPhase = ""; + mod.speedProgress = 0; + mod.speedLive = 0; + mod.speedDown = []; + mod.speedUp = []; + mod.error = ""; + speedProc.running = false; + speedProc.running = true; + } + + property Process speedProc: Process { + command: [Quickshell.env("HOME") + "/bin/speedtest", "--format=jsonl", + "--accept-license", "--accept-gdpr"] + stdout: SplitParser { + onRead: line => { + let r; + try { r = JSON.parse(line); } catch (e) { return; } + const ev = r[r.type]; + if (r.type === "ping") { + mod.speedPhase = "ping"; + mod.speedProgress = ev.progress; + mod.speedLive = 0; + } else if (r.type === "download" || r.type === "upload") { + const mbit = ev.bandwidth * 8 / 1e6; + mod.speedPhase = r.type; + mod.speedProgress = ev.progress; + mod.speedLive = mbit; + if (r.type === "download") mod.speedDown = mod.speedDown.concat([mbit]); + else mod.speedUp = mod.speedUp.concat([mbit]); + } else if (r.type === "result") { + mod.speedResult = { + down: r.download.bandwidth * 8 / 1e6, + up: r.upload.bandwidth * 8 / 1e6, + ping: r.ping.latency, + server: r.server.name + ", " + r.server.location + }; + } + } + } + onExited: code => { + mod.speedPhase = ""; + if (!mod.speedResult) mod.error = "Speedtest failed (exit " + code + ")"; + } + } + property Process ipProc: Process { command: ["ip", "-j", "-4", "addr", "show"] stdout: StdioCollector { -- cgit v1.2.3