repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

network: real iwd WiFi management via D-Bus (busctl --json)

6f0a827e95a6325e873293988cc67aea4a85b43f

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Replace the hollow Network.qml stub with real iwd connectivity management.

- network.js: pure shaping of iwd D-Bus replies (busctl --json=short). Parses
  ObjectManager.GetManagedObjects (devices/stations/networks/known) and
  Station.GetOrderedNetworks (signal+order) into view rows. No text/ANSI
  parsing — JSON.parse only. 64 node assertions, ALL PASS.
- Network.qml: discovers the station device, reads state via two busctl calls,
  builds the model. Writes via D-Bus method calls (Scan/Connect/Forget/
  Disconnect) + Powered set-property; new secured-network connect keeps
  iwctl --passphrase (needs an iwd agent for the key). selfTest 32/32.
- ConnectivityPanel: solid-dark cards (washout fix), connected highlight,
  signal-strength glyphs, stateful connect flow (open/known direct, new-psk
  reveals a password field). Bluetooth half (native Quickshell.Bluetooth)
  untouched.
- Quickshell.Networking stays forbidden (NM-only; host runs iwd).
- IPC contract preserved: shader{}/compact.signal/wifi.enabled survive for
  networkWidgetState(); select/scan/toggleWifi/forget/checkConnectivity intact.

Security: all calls use discrete argv (no sh -c); SSIDs may contain shell
metacharacters. Passphrase is a transient connect argument only — never in
stateJson/lastAction/error/logs. (iwctl --passphrase is briefly ps-visible;
acceptable on a single-user host.)

Fixtures sanitized (synthetic SSIDs/MAC/BSSID; repo pushes to GitHub).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (15)

+1038 / −330 text lines

Diff layout

quickshell/nuguland/Network.qml

Modified

+395 / −165 text lines

11import QtQuick
22import Quickshell
3import Quickshell.Io
4import "network.js" as Network
6// Service / native boundary for iwd WiFi management.
7//
8// iwd exposes a full D-Bus API (net.connman.iwd). We talk to it via
9// `busctl --json=short`, which emits structured JSON — so there is NO text/ANSI
10// parsing. Native objects (Process) stay here; all JSON shaping lives in
11// network.js. Two reads drive the model:
12// ObjectManager.GetManagedObjects -> devices / stations / networks / known
13// Station.GetOrderedNetworks -> [path, signal] strongest-first
14//
15// Writes are D-Bus method calls (Scan / Connect / Forget / Disconnect) and a
16// set-property (Powered) — except connecting to a NEW secured network, which
17// needs iwd to call back to an agent for the passphrase; for that one case we
18// use `iwctl --passphrase` (a registered agent), as a DISCRETE ARGV array.
19//
20// SECURITY: every external call uses a discrete argv array — never sh -c with
21// interpolation, because SSIDs may contain spaces / quotes / shell metachars.
22// The passphrase is a transient argument to the connect call only; it NEVER
23// enters stateJson / lastAction / error / any log line.
424Item {
525 id: root
7 readonly property string hostStack: "iwd + systemd-networkd + systemd-resolved"
8 property string error: ""
27 // --- reactive state, fed by the read Processes ---
28 property string deviceName: ""
29 property string devicePath: ""
30 property bool wifiEnabled: true
31 property bool scanning: false
32 property string lastError: ""
33 // Parsed GetManagedObjects payload (device/station/networks/knownBySsid).
34 property var managed: ({
35 })
36 property var mergedModel: []
937 property var lastAction: ({
1038 })
11 readonly property string nativeApi: "host stack: iwd + systemd-networkd + systemd-resolved"
12 readonly property var boundedActions: ["scan", "select", "forget", "toggle-wifi", "check-connectivity"]
13 readonly property bool nativeActionRoute: false
39 property int scanRetriesLeft: 0
15 function networkId(network) {
16 return String(network.id || network.name || network.ssid || "network");
41 // Emitted whenever the model is recomputed after an async read. The view
42 // connects to this to re-pull stateJson().
43 signal refreshed()
45 // D-Bus constants.
46 readonly property string svc: "net.connman.iwd"
47 readonly property string ifaceStation: "net.connman.iwd.Station"
48 readonly property string ifaceDevice: "net.connman.iwd.Device"
49 readonly property string ifaceNetwork: "net.connman.iwd.Network"
50 readonly property string ifaceKnown: "net.connman.iwd.KnownNetwork"
52 function busctlCall(objectPath, iface, method) {
53 return ["busctl", "--json=short", "call", svc, objectPath, iface, method];
1754 }
19 function cloneNetwork(network) {
20 return {
21 "id": networkId(network),
22 "ssid": String(network.ssid || network.name || network.id || "network"),
23 "state": String(network.state || (network.connected ? "connected" : "available")),
24 "signal": Number(network.signal ?? Math.round(Number(network.signalStrength || 0) * 100)),
25 "security": String(network.security || "unknown"),
26 "known": !!network.known
27 };
28 }
30 function hostNetworks() {
31 return [];
32 }
34 function sortedNetworks(rows) {
35 return rows.slice(0).sort((a, b) => {
36 const aConnected = a.state === "connected" || a.state === "Connected" || a.connected;
37 const bConnected = b.state === "connected" || b.state === "Connected" || b.connected;
38 if (aConnected !== bConnected)
39 return aConnected ? -1 : 1;
41 const aKnown = !!a.known;
42 const bKnown = !!b.known;
43 if (aKnown !== bKnown)
44 return aKnown ? -1 : 1;
46 return Number(b.signal || 0) - Number(a.signal || 0);
47 });
48 }
50 function networks() {
51 return sortedNetworks(hostNetworks());
52 }
54 function connectivityPanelContract() {
55 return {
56 "source": "Nuguland bar popouts Network.qml plus Nuguland connections Network.qml Bluetooth.qml",
57 "ownedBy": "PopoutHost.qml inline ConnectivityPanel",
58 "combinedConnectivityPanel": true,
59 "wifiToggleScanList": true,
60 "bluetoothToggleScanList": true,
61 "sortedNetworkRows": true,
62 "sortedDeviceRows": true,
63 "batteryBadges": true,
64 "serviceActionsOnly": true,
65 "rowKinds": ["wifi-network", "bluetooth-device"],
66 "nativeServices": ["Network.qml host stack", "Bluetooth.qml"],
67 "hostStack": hostStack,
68 "noShellHelpers": true
69 };
70 }
72 function activeNetworkObject() {
73 const list = networks();
74 for (let i = 0; i < list.length; i++) if (list[i].state === "connected" || list[i].state === "Connected" || list[i].connected) {
75 return list[i];
56 function activeRow() {
57 for (var i = 0; i < mergedModel.length; i++) if (mergedModel[i].connected) {
58 return mergedModel[i];
7659 }
77 for (let i = 0; i < list.length; i++) if (list[i].state === "connecting" || list[i].state === "Connecting") {
78 return list[i];
60 return null;
61 }
63 function rowForId(id) {
64 const name = String(id);
65 for (var i = 0; i < mergedModel.length; i++) if (mergedModel[i].id === name || mergedModel[i].ssid === name) {
66 return mergedModel[i];
7967 }
80 return {
81 "id": "host-network",
82 "ssid": "host-network",
83 "state": "host-managed",
84 "signal": 0,
85 "security": "systemd-networkd",
86 "known": false
87 };
88 }
90 function knownNetworksById() {
91 const indexed = {
92 };
93 const list = networks();
94 for (let i = 0; i < list.length; i++) indexed[networkId(list[i])] = cloneNetwork(list[i])
95 return indexed;
96 }
98 function wifiOn() {
99 return true;
100 }
102 function scanning() {
103 return false;
68 return null;
10469 }
10671 function role() {
107 const active = activeNetworkObject();
108 if (error.length > 0)
72 if (lastError.length > 0)
10973 return "error";
111 if (!wifiOn())
75 if (!wifiEnabled)
11276 return "ui.minor";
114 if (active.state === "connecting" || active.state === "Connecting")
78 const active = activeRow();
79 if (active && active.state === "connecting")
11580 return "warning";
117 return active.state === "connected" || active.state === "Connected" || active.state === "host-managed" ? "ui.accent" : "ui.minor";
82 return active ? "ui.accent" : "ui.minor";
83 }
85 // Build the view model from parsed managed objects + ordered list. Decorates
86 // the pure network.js rows with label/percent/glyph/role/state view fields.
87 function buildModel(ordered) {
88 const rows = Network.networkRows(managed, ordered);
89 const station = managed.station || {
90 };
91 const connecting = station.state === "connecting";
92 const out = [];
93 for (var i = 0; i < rows.length; i++) {
94 const n = rows[i];
95 const isConnecting = connecting && station.connectedNetwork === n.path;
96 out.push({
97 "id": n.id,
98 "ssid": n.ssid,
99 "security": n.security,
100 "securityLabel": Network.securityLabel(n.security),
101 "signal": n.signal,
102 "signalPercent": n.signal * 25,
103 "signalRole": Network.signalRole(n.signal),
104 "signalGlyph": Network.signalGlyph(n.signal),
105 "known": n.known,
106 "connected": n.connected,
107 "needsPassphrase": n.needsPassphrase,
108 "path": n.path,
109 "state": n.connected ? "connected" : (isConnecting ? "connecting" : "available")
110 });
111 }
112 mergedModel = out;
113 refreshed();
118114 }
120116 function stateObject() {
121 const active = cloneNetwork(activeNetworkObject());
117 const active = activeRow();
118 const compactSignal = wifiEnabled && active ? active.signal * 25 : 0;
122119 return {
123 "backend": "Network.qml",
124 "usesNativeQuickshellNetworking": false,
125 "usesHostStack": true,
126 "hostStack": hostStack,
127 "nativeApi": nativeApi,
128 "nativeBackend": "iwd-systemd-networkd-resolved",
129 "nativeWifiEnabled": wifiOn(),
130 "nativeWifiHardwareEnabled": wifiOn(),
131 "nativeCanCheckConnectivity": false,
132 "nativeConnectivity": "host-managed",
133 "nativeActionRoute": nativeActionRoute,
134 "helperProcesses": [],
135 "serviceOwnedActions": true,
136 "boundedActions": boundedActions,
137 "connectivityPanelContract": connectivityPanelContract(),
138 "scanning": scanning(),
139 "error": error,
120 "scanning": scanning,
121 "error": lastError,
122 "device": deviceName,
140123 "wifi": {
141 "enabled": wifiOn(),
142 "hardwareEnabled": wifiOn()
124 "enabled": wifiEnabled
143125 },
144126 "active": active,
145 "knownNetworks": networks().map((network) => {
146 return cloneNetwork(network);
147 }),
148 "knownNetworksById": knownNetworksById(),
127 "networks": mergedModel,
128 "knownNetworks": mergedModel,
149129 "compact": {
150130 "label": "Network",
151131 "role": role(),
152 "signal": wifiOn() ? active.signal : 0
132 "signal": compactSignal
153133 },
134 // MUST stay a real object: shell.qml:networkWidgetState() assigns
135 // state.shader.values / state.shader.history (throws on undefined).
154136 "shader": {
155 "kind": "network-mini-graph",
156 "clipped": true,
157 "source": "shaders/network-mini-graph.frag.qsb",
158 "priorArt": "Shadertoy smoothstep distance-to-line graph primitives plus matrix-rain inspired packet rain",
159 "rateSource": "Resources.qml",
160 "colors": ["ui.accent", "ui.focus", "ui.minor", "ui.backdrop", "warning", "error"]
137 "values": [],
138 "history": {
139 }
161140 },
162141 "lastAction": lastAction
163142 };
167146 return JSON.stringify(stateObject());
168147 }
170 function scan() {
171 error = "scan-owned-by-iwd";
172 lastAction = {
173 "kind": "scan",
174 "nativeActionRoute": nativeActionRoute,
175 "hostStack": hostStack
149 // selfTest() — runs the pure network.js functions over small INLINE JSON
150 // literals (the fixtures are not shipped to runtime). Returns {pass,fail,
151 // cases}, same shape as Audio/Brightness selfTest. The literals mirror the
152 // busctl --json=short reply envelope ({type,data:[value]}).
153 function selfTest() {
154 var cases = [];
155 var pass = 0;
156 var fail = 0;
157 var check = function (label, got, want) {
158 const ok = JSON.stringify(got) === JSON.stringify(want);
159 if (ok)
160 pass += 1;
161 else
162 fail += 1;
163 cases.push({
164 "case": label,
165 "ok": ok,
166 "got": got,
167 "want": want
168 });
176169 };
170 var devPath = "/net/connman/iwd/0/4";
171 var homePath = devPath + "/home_psk";
172 var fivegPath = devPath + "/fiveg_psk";
173 var cafePath = devPath + "/cafe_open";
174 // Build with bracket assignment (avoid ES6 computed keys for V4 safety).
175 var objs = {};
176 objs["/net/connman/iwd/0"] = {
177 "net.connman.iwd.Adapter": { "Powered": { "type": "b", "data": true } }
178 };
179 objs[devPath] = {
180 "net.connman.iwd.Device": {
181 "Name": { "type": "s", "data": "wlan0" },
182 "Powered": { "type": "b", "data": true },
183 "Mode": { "type": "s", "data": "station" }
184 },
185 "net.connman.iwd.Station": {
186 "State": { "type": "s", "data": "connected" },
187 "Scanning": { "type": "b", "data": false },
188 "ConnectedNetwork": { "type": "o", "data": homePath }
189 }
190 };
191 objs[homePath] = {
192 "net.connman.iwd.Network": {
193 "Name": { "type": "s", "data": "home-wifi" },
194 "Type": { "type": "s", "data": "psk" },
195 "Connected": { "type": "b", "data": true },
196 "KnownNetwork": { "type": "o", "data": "/known/home" }
197 }
198 };
199 objs[fivegPath] = {
200 "net.connman.iwd.Network": {
201 "Name": { "type": "s", "data": "home-wifi-5g" },
202 "Type": { "type": "s", "data": "psk" },
203 "Connected": { "type": "b", "data": false }
204 }
205 };
206 objs[cafePath] = {
207 "net.connman.iwd.Network": {
208 "Name": { "type": "s", "data": "Cafe Guest WiFi" },
209 "Type": { "type": "s", "data": "open" },
210 "Connected": { "type": "b", "data": false }
211 }
212 };
213 var gmo = JSON.stringify({ "type": "a{oa{sa{sv}}}", "data": [objs] });
214 var gon = JSON.stringify({
215 "type": "a(on)",
216 "data": [[[homePath, -6800], [fivegPath, -4900], [cafePath, -6500]]]
217 });
219 var m = Network.parseManaged(gmo);
220 check("parseManaged device", m.device.name, "wlan0");
221 check("parseManaged mode", m.device.mode, "station");
222 check("parseManaged powered", m.device.powered, true);
223 check("parseManaged devicePath", m.devicePath, devPath);
224 check("parseManaged state", m.station.state, "connected");
225 check("parseManaged home known", m.networks[homePath].known, true);
226 check("parseManaged 5g known", m.networks[fivegPath].known, false);
228 var ordered = Network.parseOrdered(gon);
229 check("parseOrdered length", ordered.length, 3);
230 check("parseOrdered first signal", ordered[0].signal, -6800);
232 var rows = Network.networkRows(m, ordered);
233 check("networkRows length", rows.length, 3);
234 check("rows home ssid", rows[0].ssid, "home-wifi");
235 check("rows home signal", rows[0].signal, 2);
236 check("rows home connected", rows[0].connected, true);
237 check("rows home needsPass", rows[0].needsPassphrase, false);
238 check("rows home path", rows[0].path, homePath);
239 check("rows 5g signal", rows[1].signal, 4);
240 check("rows 5g needsPass", rows[1].needsPassphrase, true);
241 check("rows cafe ssid (spaces)", rows[2].ssid, "Cafe Guest WiFi");
242 check("rows cafe needsPass", rows[2].needsPassphrase, false);
244 check("signalBars(-4900)", Network.signalBars(-4900), 4);
245 check("signalBars(-6800)", Network.signalBars(-6800), 2);
246 check("signalBars(NaN)", Network.signalBars("x"), 0);
247 check("signalRole(0)", Network.signalRole(0), "ui.minor");
248 check("signalRole(2)", Network.signalRole(2), "ui.accent");
249 check("signalRole(4)", Network.signalRole(4), "content.accent");
250 check("securityLabel psk", Network.securityLabel("psk"), "WPA");
251 check("securityLabel open", Network.securityLabel("open"), "Open");
252 check("needsPassphrase open", Network.needsPassphrase("open", false), false);
253 check("needsPassphrase psk unknown", Network.needsPassphrase("psk", false), true);
254 check("networkId empty non-empty", Network.networkId("").length > 0, true);
255 check("signalGlyph(0) non-empty", Network.signalGlyph(0).length > 0, true);
256 check("parseManaged(null) safe", Network.parseManaged(null).devicePath, "");
258 return JSON.stringify({
259 "pass": pass,
260 "fail": fail,
261 "cases": cases
262 });
263 }
265 // --- read cadence ------------------------------------------------------
267 // refresh(): one call returns every iwd object + properties; its handler
268 // then reads the ordered list (which needs the discovered device path).
269 function refresh() {
270 gmoProc.exec(["busctl", "--json=short", "call", svc, "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"]);
271 }
273 // --- actions -----------------------------------------------------------
275 function scan() {
276 if (!devicePath) {
277 refresh();
278 return stateJson();
279 }
280 scanning = true;
281 lastError = "";
282 scanRetriesLeft = 2;
283 scanProc.exec(busctlCall(devicePath, ifaceStation, "Scan"));
284 scanTimer.start();
177285 return stateJson();
178286 }
288 // connect(ssid, passphrase) — in-process secured/open/known connect. NOT an
289 // IPC handler. open/known go over D-Bus Network.Connect (no agent needed).
290 // A NEW secured network needs the passphrase handed to iwd via an agent, so
291 // it uses `iwctl --passphrase`. The passphrase is a transient argv only.
292 function connect(ssid, passphrase) {
293 const name = String(ssid);
294 const pp = (passphrase === undefined || passphrase === null) ? "" : String(passphrase);
295 const row = rowForId(name);
296 lastError = "";
297 lastAction = {
298 "kind": "connect",
299 "ssid": name
300 };
301 if (pp.length > 0) {
302 // New secured network: iwctl registers an agent and supplies the key.
303 if (deviceName)
304 actionProc.exec(["iwctl", "--passphrase", pp, "station", deviceName, "connect", name]);
306 } else if (row && row.path) {
307 actionProc.exec(busctlCall(row.path, ifaceNetwork, "Connect"));
308 }
309 return stateJson();
310 }
312 // select(id) — IPC entry: connect a known/open network by id (= ssid).
180313 function select(id) {
181 const networkIdValue = String(id);
182 const list = networks();
183 let selected = null;
184 for (let i = 0; i < list.length; i++) if (networkId(list[i]) === networkIdValue) {
185 selected = list[i];
186 }
187 if (!selected) {
188 error = "unknown-network";
189 lastAction = {
190 "kind": "select",
191 "id": networkIdValue,
192 "nativeActionRoute": nativeActionRoute,
193 "hostStack": hostStack
194 };
195 return stateJson();
196 }
197 error = "select-owned-by-iwd";
314 const name = String(id);
198315 lastAction = {
199316 "kind": "select",
200 "id": networkIdValue,
201 "nativeActionRoute": nativeActionRoute,
202 "hostStack": hostStack
317 "id": name
203318 };
319 return connect(name, "");
320 }
322 function forget(id) {
323 const name = String(id);
324 lastAction = {
325 "kind": "forget",
326 "id": name
327 };
328 const knownPath = (managed.knownBySsid || {})[name];
329 if (knownPath)
330 actionProc.exec(busctlCall(knownPath, ifaceKnown, "Forget"));
204332 return stateJson();
205333 }
207335 function toggleWifi(enabled) {
208 error = "wifi-toggle-owned-by-iwd";
336 const on = !!enabled;
209337 lastAction = {
210338 "kind": "toggle-wifi",
211 "enabled": wifiOn(),
212 "nativeActionRoute": nativeActionRoute,
213 "hostStack": hostStack
339 "enabled": on
214340 };
341 if (devicePath) {
342 wifiEnabled = on;
343 actionProc.exec(["busctl", "set-property", svc, devicePath, ifaceDevice, "Powered", "b", on ? "true" : "false"]);
344 }
215345 return stateJson();
216346 }
218 function forget(id) {
219 const networkIdValue = String(id);
348 function disconnect() {
220349 lastAction = {
221 "kind": "forget",
222 "id": networkIdValue,
223 "nativeActionRoute": nativeActionRoute,
224 "hostStack": hostStack
350 "kind": "disconnect"
225351 };
352 if (devicePath)
353 actionProc.exec(busctlCall(devicePath, ifaceStation, "Disconnect"));
226355 return stateJson();
227356 }
229358 function checkConnectivity() {
230359 lastAction = {
231 "kind": "check-connectivity",
232 "nativeActionRoute": nativeActionRoute,
233 "hostStack": hostStack
360 "kind": "check-connectivity"
234361 };
362 refresh();
235363 return stateJson();
236364 }
366 Component.onCompleted: refresh()
368 // --- read Processes ----------------------------------------------------
370 Process {
371 id: gmoProc
373 running: false
375 stdout: StdioCollector {
376 waitForEnd: true
377 onStreamFinished: {
378 root.managed = Network.parseManaged(this.text);
379 const m = root.managed;
380 if (!m.device || !m.devicePath) {
381 root.lastError = "no-wifi-device";
382 root.deviceName = "";
383 root.devicePath = "";
384 root.buildModel([]);
385 return ;
386 }
387 root.deviceName = m.device.name;
388 root.devicePath = m.devicePath;
389 root.wifiEnabled = m.device.powered;
390 root.lastError = "";
391 if (m.device.powered) {
392 gonProc.exec(root.busctlCall(m.devicePath, root.ifaceStation, "GetOrderedNetworks"));
393 } else {
394 root.buildModel([]);
395 }
396 }
397 }
399 }
401 Process {
402 id: gonProc
404 running: false
406 stdout: StdioCollector {
407 waitForEnd: true
408 onStreamFinished: {
409 root.buildModel(Network.parseOrdered(this.text));
410 }
411 }
413 }
415 // --- action Processes --------------------------------------------------
417 Process {
418 id: scanProc
420 running: false
422 stderr: StdioCollector {
423 id: scanErr
425 waitForEnd: true
426 }
428 // "Operation already in progress" = scan already running, NOT a hard
429 // error: keep scanning, let the retry timer re-read the list.
430 onExited: (exitCode, exitStatus) => {
431 const err = String(scanErr.text || "");
432 if (exitCode !== 0 && err.indexOf("already in progress") < 0)
433 root.lastError = "scan-failed";
435 }
436 }
438 // Shared action runner. Re-reads state when done so the model reflects the
439 // effect. stderr is intentionally NOT surfaced verbatim (belt-and-suspenders:
440 // a connect arg must never leak via an error string).
441 Process {
442 id: actionProc
444 running: false
446 onExited: (exitCode, exitStatus) => {
447 root.refresh();
448 }
449 }
451 // Delayed/polled re-read after an async scan (results lag ~1-4 s).
452 Timer {
453 id: scanTimer
455 interval: 2000
456 repeat: true
457 running: false
458 onTriggered: {
459 root.refresh();
460 root.scanRetriesLeft -= 1;
461 if (root.scanRetriesLeft <= 0) {
462 root.scanning = false;
463 running = false;
464 }
465 }
466 }

quickshell/nuguland/PopoutHost.qml

Modified

+238 / −41 text lines

26632663 required property QtObject networkService
26642664 required property QtObject bluetoothService
26652665 property var networkState: networkService ? Util.parseJson(networkService.stateJson(), {
2666 "networks": [],
26662667 "knownNetworks": [],
2667 "connectivityPanelContract": {
2668 },
26692668 "wifi": {
2669 },
2670 "compact": {
26712672 }) : ({
2673 "networks": [],
26722674 "knownNetworks": [],
2673 "connectivityPanelContract": {
2674 },
26752675 "wifi": {
2676 },
2677 "compact": {
26772679 })
26782680 property var bluetoothState: bluetoothService ? Util.parseJson(bluetoothService.stateJson(), {
26842686 "adapter": {
26862688 })
2687 readonly property var panel: networkState.connectivityPanelContract || ({
2688 })
2689 // ssid whose inline passphrase field is currently revealed ("" = none).
2690 // Holds only an ssid (not a secret); the passphrase lives solely in the
2691 // TextInput.text and is cleared on submit, never bound into networkState.
2692 property string expandedSsid: ""
26912694 function refreshNetwork(text) {
26922695 networkState = Util.parseJson(text, networkState);
2726 // Secured-connect for a new network: connect(ssid, passphrase) is the
2727 // in-process entry (NOT an IPC handler). The passphrase is a transient
2728 // argument only — never stored on root / networkState / any logged field.
2729 function connectSecured(ssid, passphrase) {
2730 if (networkService)
2731 refreshNetwork(networkService.connect(ssid, passphrase));
2733 }
27232735 function toggleBluetooth() {
27242736 if (bluetoothService)
27252737 refreshBluetooth(bluetoothService.toggle(!(bluetoothState.adapter && bluetoothState.adapter.state === "powered")));
27512763 if (role === "ui.minor")
27522764 return theme.ui.minor;
2766 if (role === "content.accent")
2767 return theme.content.accent;
27542769 return theme.ui.accent;
27572772 spacing: 10
27582773 width: parent ? parent.width : 0
2775 // Async reads (scan retries, post-action refresh) update the service
2776 // model and emit refreshed(); re-pull stateJson so the scan spinner
2777 // clears and new/connected rows land without a user action.
2778 Connections {
2779 target: root.networkService
2781 function onRefreshed() {
2782 if (root.networkService)
2783 root.refreshNetwork(root.networkService.stateJson());
2785 }
2786 }
27602788 Row {
27612789 objectName: "networkRateRow"
27622790 width: parent.width
28412869 Repeater {
2842 model: root.networkState.knownNetworks || []
2870 model: root.networkState.networks || []
2844 delegate: Rectangle {
2872 delegate: Column {
28452873 id: wifiRow
28472875 required property var modelData
2848 readonly property bool active: modelData.state === "connected" || modelData.state === "Connected"
2876 readonly property bool active: modelData.connected === true
2877 readonly property bool revealed: root.expandedSsid === modelData.ssid
28502879 width: root.width
2851 height: 34
2852 radius: 10
2853 color: root.theme ? root.theme.withAlpha(active ? root.theme.ui.focus : root.theme.ui.minor, active ? 0.24 : 0.1) : "transparent"
2854 border.width: 0
2855 border.color: root.roleColor(active ? "ui.accent" : modelData.state === "connecting" ? "warning" : "ui.minor")
2880 spacing: 4
2857 NuguText {
2858 anchors.left: parent.left
2859 anchors.leftMargin: 8
2860 anchors.verticalCenter: parent.verticalCenter
2861 theme: root.theme
2862 text: wifiRow.modelData.ssid
2863 width: parent.width - 122
2864 elide: Text.ElideRight
2865 }
2882 // --- washout-fixed card: solid dark base, identity via thin
2883 // accent bar + border; signal colour on bar + glyph, not fill.
2884 Rectangle {
2885 width: parent.width
2886 height: 40
2887 radius: 12
2888 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, wifiRow.active ? 0.82 : 0.55) : "#333333"
2889 border.width: wifiRow.active ? 2 : 1
2890 border.color: root.theme ? (wifiRow.active ? root.theme.ui.accent : (wifiRow.modelData.state === "connecting" ? root.roleColor("warning") : root.theme.withAlpha(root.theme.ui.minor, 0.45))) : "white"
2867 NuguText {
2868 anchors.right: parent.right
2869 anchors.rightMargin: 8
2870 anchors.verticalCenter: parent.verticalCenter
2871 theme: root.theme
2872 variant: "meta"
2873 text: `${wifiRow.modelData.signal}% ${wifiRow.modelData.security}`
2874 }
2876 MouseArea {
2877 anchors.fill: parent
2878 acceptedButtons: Qt.LeftButton | Qt.MiddleButton
2879 onClicked: (event) => {
2880 if (event.button === Qt.MiddleButton)
2881 root.forgetNetwork(wifiRow.modelData.id);
2882 else
2883 root.selectNetwork(wifiRow.modelData.id);
2892 // left accent bar — only on the connected network
2893 Rectangle {
2894 anchors.left: parent.left
2895 anchors.top: parent.top
2896 anchors.bottom: parent.bottom
2897 anchors.margins: 2
2898 width: 3
2899 radius: 2
2900 color: root.theme ? root.theme.ui.accent : "transparent"
2901 opacity: wifiRow.active ? 1 : 0
2904 Text {
2905 id: wifiGlyph
2907 anchors.left: parent.left
2908 anchors.leftMargin: 12
2909 anchors.verticalCenter: parent.verticalCenter
2910 font.family: "Symbols Nerd Font Mono"
2911 font.pixelSize: 18
2912 text: wifiRow.modelData.signalGlyph || ""
2913 color: root.roleColor(wifiRow.modelData.signalRole || "ui.minor")
2914 }
2916 Rectangle {
2917 id: wifiAction
2919 anchors.right: parent.right
2920 anchors.rightMargin: 10
2921 anchors.verticalCenter: parent.verticalCenter
2922 width: 66
2923 height: 26
2924 radius: 9
2925 color: root.theme ? root.theme.withAlpha(wifiRow.active ? root.theme.error : root.theme.ui.accent, wifiRow.revealed ? 0.34 : 0.18) : "transparent"
2926 border.width: 1
2927 border.color: root.theme ? root.theme.withAlpha(wifiRow.active ? root.theme.error : root.theme.ui.accent, 0.7) : "white"
2929 NuguText {
2930 anchors.centerIn: parent
2931 theme: root.theme
2932 variant: "meta"
2933 text: wifiRow.active ? "forget" : (wifiRow.modelData.needsPassphrase ? (wifiRow.revealed ? "cancel" : "connect") : "connect")
2934 }
2936 MouseArea {
2937 anchors.fill: parent
2938 onClicked: {
2939 if (wifiRow.active) {
2940 root.expandedSsid = "";
2941 root.forgetNetwork(wifiRow.modelData.id);
2942 } else if (wifiRow.modelData.needsPassphrase) {
2943 root.expandedSsid = wifiRow.revealed ? "" : wifiRow.modelData.ssid;
2944 } else {
2945 root.expandedSsid = "";
2946 root.selectNetwork(wifiRow.modelData.id);
2947 }
2948 }
2949 }
2951 }
2953 NuguText {
2954 id: wifiLabel
2956 anchors.right: wifiAction.left
2957 anchors.rightMargin: 10
2958 anchors.verticalCenter: parent.verticalCenter
2959 theme: root.theme
2960 variant: "meta"
2961 text: wifiRow.active ? "connected" : (wifiRow.modelData.securityLabel || "")
2962 color: root.roleColor(wifiRow.active ? "content.accent" : "ui.minor")
2963 }
2965 NuguText {
2966 anchors.left: wifiGlyph.right
2967 anchors.leftMargin: 10
2968 anchors.right: wifiLabel.left
2969 anchors.rightMargin: 10
2970 anchors.verticalCenter: parent.verticalCenter
2971 theme: root.theme
2972 text: wifiRow.modelData.ssid
2973 elide: Text.ElideRight
2974 }
2976 }
2978 // --- inline passphrase entry for a NEW secured network.
2979 // echoMode Password; text lives only here, cleared on submit,
2980 // never bound into networkState / any serialized property.
2981 Rectangle {
2982 id: wifiPpRow
2984 function submit() {
2985 root.connectSecured(wifiRow.modelData.ssid, wifiPp.text);
2986 wifiPp.text = "";
2987 root.expandedSsid = "";
2988 }
2990 visible: wifiRow.revealed
2991 width: parent.width
2992 height: visible ? 34 : 0
2993 radius: 10
2994 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.7) : "#333333"
2995 border.width: 1
2996 border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.6) : "white"
2997 onVisibleChanged: {
2998 if (visible)
2999 Qt.callLater(function() {
3000 wifiPp.forceActiveFocus();
3001 });
3002 }
3004 TextInput {
3005 id: wifiPp
3007 anchors.left: parent.left
3008 anchors.leftMargin: 12
3009 anchors.right: wifiPpConfirm.left
3010 anchors.rightMargin: 10
3011 anchors.verticalCenter: parent.verticalCenter
3012 verticalAlignment: TextInput.AlignVCenter
3013 color: root.theme ? root.theme.content.normal : "white"
3014 selectionColor: root.theme ? root.theme.ui.focus : "#ffffff"
3015 selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
3016 font.family: "IBM Plex Sans"
3017 font.pixelSize: 13
3018 echoMode: TextInput.Password
3019 clip: true
3020 onAccepted: wifiPpRow.submit()
3021 Keys.onReturnPressed: (event) => {
3022 event.accepted = true;
3023 wifiPpRow.submit();
3024 }
3025 Keys.onEnterPressed: (event) => {
3026 event.accepted = true;
3027 wifiPpRow.submit();
3028 }
3029 Keys.onEscapePressed: (event) => {
3030 event.accepted = true;
3031 wifiPp.text = "";
3032 root.expandedSsid = "";
3033 }
3034 }
3036 NuguText {
3037 anchors.left: parent.left
3038 anchors.leftMargin: 12
3039 anchors.verticalCenter: parent.verticalCenter
3040 visible: wifiPp.text.length === 0
3041 theme: root.theme
3042 variant: "meta"
3043 text: "passphrase"
3044 opacity: 0.7
3045 }
3047 Rectangle {
3048 id: wifiPpConfirm
3050 anchors.right: parent.right
3051 anchors.rightMargin: 6
3052 anchors.verticalCenter: parent.verticalCenter
3053 width: 56
3054 height: 24
3055 radius: 8
3056 color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.22) : "transparent"
3057 border.width: 1
3058 border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.7) : "white"
3060 NuguText {
3061 anchors.centerIn: parent
3062 theme: root.theme
3063 variant: "meta"
3064 text: "join"
3065 }
3067 MouseArea {
3068 anchors.fill: parent
3069 onClicked: wifiPpRow.submit()
3070 }
3072 }
3080 NuguText {
3081 visible: !!(root.networkState.wifi && root.networkState.wifi.enabled) && (!root.networkState.networks || root.networkState.networks.length === 0)
3082 theme: root.theme
3083 variant: "meta"
3084 text: root.networkState.scanning ? "scanning…" : "no networks"
3085 opacity: 0.7
3086 }
28933090 Rectangle {

quickshell/nuguland/docs/superpowers/specs/2026-06-29-network-popup-redesign-design.md

Modified

+79 / −64 text lines

11# Network (Connectivity) Popup Redesign
33**Date:** 2026-06-29
4**Status:** approved (autonomous — standing /goal "ultracode next are audio, bright, networn and power")
5**Popup:** 3 of 4 (audio ✅, brightness ✅, network ▶, power ⏳)
4**Status:** shipped (autonomous — standing /goal "ultracode next are audio, bright, networn and power")
5**Popup:** 3 of 4 (audio ✅, brightness ✅, network ✅, power ⏳)
6
7> **PIVOT (post-build):** the read path was first built on `iwctl` ANSI-table
8> parsing (worked, verified live). The user asked whether iwd has a
9> machine-readable interface — it does: the **iwd D-Bus API** (`net.connman.iwd`),
10> and `busctl --json=short` emits clean JSON against it. We pivoted the read
11> path (and most writes) to D-Bus JSON, deleting ~150 lines of fragile
12> ANSI/fixed-column parsing (matches the standing directive "rely on APIs more
13> than custom code, the less code the better"). The sections below are updated
14> to the **as-shipped D-Bus design**; the earlier iwctl approach is noted where
15> still relevant (the one new-secured-network connect keeps `iwctl --passphrase`).
717## Problem
2636| Layer | File | Responsibility |
2737|-------|------|----------------|
28| Pure logic | `network.js` | Parse raw `iwctl` text → plain data; shape/sort/role/label. NO I/O. Dual-mode export (node tests + QML import), like `clip.js`/`audio.js`/`brightness.js`. |
29| Service (native boundary) | `Network.qml` | Spawn `iwctl` via `Process`, feed stdout to `network.js`, hold model + cadence, expose IPC. |
38| Pure logic | `network.js` | `JSON.parse` busctl D-Bus replies → plain data; shape/role/label. NO I/O. Dual-mode export (node tests + QML import), like `clip.js`/`audio.js`/`brightness.js`. |
39| Service (native boundary) | `Network.qml` | Spawn `busctl` (and `iwctl` for one case) via `Process`, feed stdout to `network.js`, hold model + cadence, expose IPC. |
3040| View | `PopoutHost.qml` ConnectivityPanel | Pure graphical — WiFi list + connect flow + toggle; Bluetooth half unchanged. |
32**Native boundary rule (unchanged):** native objects (`Process`,
33`Quickshell.Bluetooth`) stay in QML. Only pure text-parsing / shaping /
34formatting moves to `network.js` as plain-data functions. Raw `iwctl`
35output (ANSI intact) is passed to `network.js`; **QML never pre-strips
36ANSI** — signal strength is encoded in it.
42**Native boundary rule:** native objects (`Process`, `Quickshell.Bluetooth`)
43stay in QML. Only pure JSON shaping moves to `network.js` as plain-data
44functions.
38## iwctl command surface
46## D-Bus command surface (`busctl --json=short`)
40Device name is **discovered** (`iwctl device list` → first `station`-mode
41device), never hardcoded `wlan0`.
48iwd object service is `net.connman.iwd` (system bus). Device path is
49**discovered** from `GetManagedObjects` (first `net.connman.iwd.Device` with
50`Mode == "station"`), never hardcoded `wlan0`. Network/known objects carry the
51SSID hex-encoded in their path, but `Name` is already decoded.
4353```
44list devices: iwctl device list
45list networks: iwctl station <dev> get-networks
46station state: iwctl station <dev> show
47known nets: iwctl known-networks
48scan (async): iwctl station <dev> scan # returns immediately
49connect known/open: iwctl station <dev> connect <ssid>
50connect new psk: iwctl --passphrase <pp> station <dev> connect <ssid>
51forget: iwctl known-networks <ssid> forget
52toggle wifi: iwctl device <dev> set-property Powered on|off
53disconnect: iwctl station <dev> disconnect
54read all: busctl --json=short call net.connman.iwd / \
55 org.freedesktop.DBus.ObjectManager GetManagedObjects
56read signal: busctl --json=short call net.connman.iwd <dev> \
57 net.connman.iwd.Station GetOrderedNetworks # [[path,dBm*100],…] sorted
58scan(async): busctl --json=short call net.connman.iwd <dev> net.connman.iwd.Station Scan
59connect: busctl --json=short call net.connman.iwd <netPath> net.connman.iwd.Network Connect
60forget: busctl --json=short call net.connman.iwd <knownPath> net.connman.iwd.KnownNetwork Forget
61disconnect: busctl --json=short call net.connman.iwd <dev> net.connman.iwd.Station Disconnect
62toggle wifi: busctl set-property net.connman.iwd <dev> net.connman.iwd.Device Powered b true|false
63connect NEW psk (hybrid): iwctl --passphrase <pp> station <devName> connect <ssid>
5464```
66**Why the one `iwctl` hold-out:** `Network.Connect` over D-Bus on a *new*
67secured network makes iwd call back to a registered **agent** for the
68passphrase. Exporting a D-Bus agent object from QML is impractical, so for
69that single case we use `iwctl --passphrase` (iwctl registers its own agent).
70Open and **known** networks connect over pure D-Bus (no agent needed — open
71has no secret; known has iwd's stored PSK).
5673### Async scan (must not look broken)
58`scan` returns immediately; `get-networks` does **not** reflect new results
59for ~1–4 s. So:
60- `scan()` sets a real `scanning` state, spawns the scan, then re-reads
61 `get-networks` on a delayed/polled Timer (≈2 s, a couple of retries).
62- `"Operation already in progress"` on stderr = scan-in-progress, **not** a
63 hard error → keep `scanning=true`, don't surface as error.
75`Station.Scan` returns immediately; the network list lags ~1–4 s. So:
76- `scan()` sets a real `scanning` state, calls `Scan`, then re-reads on a
77 delayed/polled Timer (≈2 s, a couple of retries).
78- A scan that errors with "already in progress" = scan-in-progress, **not**
79 a hard error → keep `scanning=true`.
65## `network.js` — pure parser API (node-tested against fixtures)
81## `network.js` — pure shaping API (node-tested against JSON fixtures)
67Fixtures: `test-fixtures/iwctl/*.txt` (synthetic, byte-identical to real
68`iwctl` format — ANSI resets carried to line starts, fixed-width columns,
69signal bars as bright-`*` then grey-`\x1b[1;90m*\x1b[0m`).
83Fixtures: `test-fixtures/iwd/*.json` (real busctl `--json=short` replies,
84**sanitized** — synthetic SSIDs/MAC/BSSID, structure preserved):
85`get-managed-objects.json`, `ordered-networks.json`.
7187```
72parseDevices(raw) -> [{ name, address, powered:bool, mode }]
73 deviceForStation(devices) -> first mode==="station" name
74parseNetworks(raw) -> [{ ssid, security, signal:0..4, connected:bool }]
75parseStation(raw) -> { scanning:bool, state, connectedNetwork, ipv4, security, rssi }
76parseKnown(raw) -> [{ ssid, security }]
88unwrap(raw) -> peels busctl's { type, data:[value] } wrapper
89prop(iface, name, fb) -> a D-Bus { type, data } property value, or fb
90signalBars(centiDbm) -> 0..4 (dBm*100 thresholds: ≥-60→4, ≥-67→3, ≥-74→2, else 1; NaN→0)
91parseManaged(rawGmo) -> { devicePath, device:{name,powered,mode},
92 station:{state,scanning,connectedNetwork},
93 networks:{ <path>:{ssid,security,connected,known} },
94 knownBySsid:{ <ssid>:<knownPath> } }
95parseOrdered(rawGon) -> [{ path, signal:centiDbm }] in iwd order
96networkRows(managed, ordered) -> joined view rows, iwd order:
97 [{ id, ssid, security, signal:0..4, connected, known, needsPassphrase, path }]
7798```
79100Shaping / view helpers (pure):
80101```
81mergeNetworks(networks, known, station) -> enrich each net:
82 { ...net, known:bool, connected:bool, needsPassphrase:bool }
83102needsPassphrase(security, known) -> security!=="open" && !known
84103signalRole(bars) -> "ui.minor" (≤1) | "ui.accent" (2–3) | "content.accent" (4)
85104signalGlyph(bars) -> nerd-font wifi glyph by strength
86securityLabel(sec) -> "open" -> "Open", "psk" -> "WPA", "8021x" -> "Enterprise"
105securityLabel(sec) -> "open"→"Open", "psk"→"WPA", "8021x"→"Enterprise"
87106networkId(ssid) -> stable id (ssid itself; never empty)
88sortNetworks(list) -> connected first, then signal desc, then ssid asc
89107```
91### Parser correctness facts (bake into tests)
109### Correctness facts (baked into tests)
93- **Signal bars** = count of bright `*` *before* the first
94 `\x1b[1;90m` grey marker in the signal column; if no grey marker, all 4
95 bright. Fixture rows: `home-wifi`→2, `home-wifi-5g`→4,
96 `Cafe Guest WiFi`→3, `Reading Room`→2, `Neighbor 2G`→1.
97- **Names contain spaces** (`Cafe Guest WiFi`, `Reading Room`) → fixed-column
98 slice (visible cols: name 6–39, security 40–59, signal 60+), NOT
99 whitespace split. Strip ANSI for name/security columns only.
100- **Connected marker** = visible `> ` at cols 2–3 (`home-wifi` is connected).
101- **Leading `\x1b[0m`**: the first data row begins with a stray reset
102 (iwctl carries the previous line's reset to the next line's start) — must
103 not break lead/marker detection.
104- **Edge fixtures must not throw**: `station-show-disconnected.txt`
105 (no Connected network / RSSI lines), `device-list-off.txt`
106 (`Powered off`), `get-networks-empty.txt` (header only, zero rows).
111- **`known`** = the per-network `KnownNetwork` D-Bus property is **present**
112 (iwd omits it when the net isn't known) — no name-join needed.
113- **Order** comes from `GetOrderedNetworks` (iwd already lists the connected
114 net first, then by descending strength) — no client-side re-sort.
115- **`networkRows` carries `path`** so the service calls `Connect` on the exact
116 D-Bus object (no ssid→path guessing); `forget` uses `knownBySsid[ssid]`.
117- **Names with spaces** (`Cafe Guest WiFi`) arrive decoded in `Name` — verbatim.
118- **Robustness:** malformed/empty replies must not throw — `unwrap` of empty
119 `data:[]`→null; `parseManaged(null)`/`parseOrdered(null)` return empty;
120 an ordered path with no matching managed network is skipped.
108`network.test.js` prints `network.test.js: ALL PASS`, asserts the specific
109rows above + every edge fixture.
122`network.test.js` prints `network.test.js: ALL PASS` (64 assertions).
111124## `Network.qml` — service
113126- Replace all stub bodies with real `Process`-driven impls.
114- Discover device once on load; cache name.
115- `refresh()`: run `device list`, `get-networks`, `known-networks`,
116 `station show`; parse each; `mergeNetworks` → model.
117- `scan()`: spawn scan, set `scanning`, delayed re-`refresh()`.
118- `connect(ssid, passphrase)`, `forget(ssid)`, `toggleWifi(on)`,
119 `disconnect()` — all real.
127- `refresh()`: one `GetManagedObjects` call (discovers device path + all
128 state) → `parseManaged`; if powered, follow with `GetOrderedNetworks` →
129 `parseOrdered` → `networkRows` → model (`buildModel` decorates with
130 label/percent/glyph/role/state).
131- `scan()`: `Station.Scan`, set `scanning`, delayed re-`refresh()`.
132- `connect(ssid, passphrase)` (open/known via D-Bus `Network.Connect`,
133 new-psk via `iwctl --passphrase`), `forget(ssid)` (`KnownNetwork.Forget`),
134 `toggleWifi(on)` (`Device.Powered` set-property), `disconnect()` — all real.
120135- Preserve the IPC contract (consumed by `shell.qml` IpcHandlers /
121136 `stateJson`): `stateJson`, `scan`, `select`/`connect`, `toggleWifi`,
122137 `forget`, `checkConnectivity`. Add `selfTest()` (runs parser over fixtures

quickshell/nuguland/network.js

Added
new file mode 100644

+208 / −0 text lines

1// network.js — pure iwd D-Bus (busctl --json) shaping. NO I/O.
2// Dual-mode: node `require` (tests) + QML import ("network.js" as Network).
3// Same pattern as audio.js / brightness.js / clip.js. No `.pragma library`.
4//
5// iwd exposes a full D-Bus API (net.connman.iwd). `busctl --json=short` emits
6// structured JSON, so there is NO text/ANSI parsing — we JSON.parse two calls:
7// ObjectManager.GetManagedObjects -> devices, stations, networks, known nets
8// Station.GetOrderedNetworks -> [path, signalStrength] strongest-first
9// Network names arrive already decoded; signal is int dBm*100 (e.g. -6800).
11// --- busctl JSON helpers ---------------------------------------------------
13// busctl --json wraps a reply as { "type": "...", "data": [ <value> ] }.
14// Unwrap to the single payload value. Accepts a raw string or a parsed object.
15function unwrap(raw) {
16 if (raw === undefined || raw === null) return null;
17 var obj = typeof raw === "string" ? JSON.parse(raw) : raw;
18 if (obj && Object.prototype.hasOwnProperty.call(obj, "data")
19 && Array.isArray(obj.data)) {
20 return obj.data.length > 0 ? obj.data[0] : null;
21 }
22 return obj;
23}
25// A D-Bus property value is { "type": "x", "data": <value> }. Pull data or fb.
26function prop(iface, name, fb) {
27 if (iface && iface[name] && iface[name].data !== undefined) return iface[name].data;
28 return fb;
29}
31// --- Signal -----------------------------------------------------------------
33// signalBars(centiDbm) — iwd reports signal as dBm*100. Map to 0..4 bars using
34// the same thresholds iwctl itself renders. Non-finite => 0.
35function signalBars(centiDbm) {
36 var v = Number(centiDbm);
37 if (!isFinite(v)) return 0;
38 if (v >= -6000) return 4;
39 if (v >= -6700) return 3;
40 if (v >= -7400) return 2;
41 return 1;
42}
44// --- Parsers (JSON -> plain data) ------------------------------------------
46// parseManaged(rawGmo) -> {
47// devicePath, device:{name,powered,mode}|null,
48// station:{state,scanning,connectedNetwork}|null,
49// networks: { <path>: {ssid,security,connected,known} },
50// knownBySsid: { <ssid>: <knownNetworkPath> } }
51// Picks the FIRST station-mode device.
52function parseManaged(rawGmo) {
53 var d = unwrap(rawGmo) || {};
54 var out = {
55 devicePath: "",
56 device: null,
57 station: null,
58 networks: {},
59 knownBySsid: {}
60 };
61 for (var path in d) {
62 if (!Object.prototype.hasOwnProperty.call(d, path)) continue;
63 var ifaces = d[path];
65 var dev = ifaces["net.connman.iwd.Device"];
66 if (dev && prop(dev, "Mode", "") === "station" && out.devicePath === "") {
67 out.devicePath = path;
68 out.device = {
69 name: prop(dev, "Name", ""),
70 powered: !!prop(dev, "Powered", false),
71 mode: "station"
72 };
73 var st = ifaces["net.connman.iwd.Station"];
74 if (st) {
75 out.station = {
76 state: prop(st, "State", ""),
77 scanning: !!prop(st, "Scanning", false),
78 connectedNetwork: prop(st, "ConnectedNetwork", "")
79 };
80 }
81 }
83 var net = ifaces["net.connman.iwd.Network"];
84 if (net) {
85 out.networks[path] = {
86 ssid: prop(net, "Name", ""),
87 security: prop(net, "Type", ""),
88 connected: !!prop(net, "Connected", false),
89 // iwd exposes a KnownNetwork property ONLY when the net is known.
90 known: Object.prototype.hasOwnProperty.call(net, "KnownNetwork")
91 };
92 }
94 var kn = ifaces["net.connman.iwd.KnownNetwork"];
95 if (kn) {
96 var kssid = prop(kn, "Name", "");
97 if (kssid !== "") out.knownBySsid[kssid] = path;
98 }
99 }
100 return out;
101}
103// parseOrdered(rawGon) -> [{ path, signal:centiDbm }] in iwd order (the API
104// already lists the connected network first, then by descending strength).
105function parseOrdered(rawGon) {
106 var arr = unwrap(rawGon);
107 var out = [];
108 if (!Array.isArray(arr)) return out;
109 for (var i = 0; i < arr.length; i++) {
110 var pair = arr[i];
111 if (!Array.isArray(pair) || pair.length < 2) continue;
112 out.push({ path: pair[0], signal: pair[1] });
113 }
114 return out;
115}
117// networkRows(managed, ordered) -> view rows, in iwd order, joining the signal
118// (from ordered) with name/type/known/connected (from managed). Carries the
119// D-Bus object `path` so the service can call Connect on the right object.
120// [{ id, ssid, security, signal:0..4, connected, known, needsPassphrase, path }]
121function networkRows(managed, ordered) {
122 var nets = (managed && managed.networks) ? managed.networks : {};
123 var list = ordered || [];
124 var rows = [];
125 for (var i = 0; i < list.length; i++) {
126 var o = list[i];
127 var n = nets[o.path];
128 if (!n) continue;
129 rows.push({
130 id: networkId(n.ssid),
131 ssid: n.ssid,
132 security: n.security,
133 signal: signalBars(o.signal),
134 connected: n.connected,
135 known: n.known,
136 needsPassphrase: needsPassphrase(n.security, n.known),
137 path: o.path
138 });
139 }
140 return rows;
141}
143// --- Shaping / view helpers ------------------------------------------------
145// needsPassphrase(security, known) — secured AND iwd has no stored secret.
146function needsPassphrase(security, known) {
147 return security !== "open" && !known;
148}
150// signalRole(bars) — theme token; weak/medium/strong.
151function signalRole(bars) {
152 if (bars <= 1) return "ui.minor";
153 if (bars <= 3) return "ui.accent";
154 return "content.accent";
155}
157// --- Nerd Font md-wifi_strength glyphs (astral codepoints). Built from
158// codepoints to avoid hand-written surrogate pairs. ---
159function fromCodePoint(n) {
160 if (n < 0x10000) return String.fromCharCode(n);
161 var c = n - 0x10000;
162 return String.fromCharCode(0xD800 + (c >> 10), 0xDC00 + (c & 0x3FF));
163}
164var WIFI_GLYPHS = [
165 fromCodePoint(0xF092F), // 0: wifi-strength-outline
166 fromCodePoint(0xF091F), // 1
167 fromCodePoint(0xF0922), // 2
168 fromCodePoint(0xF0925), // 3
169 fromCodePoint(0xF0928) // 4
170];
172// signalGlyph(bars) — nerd-font wifi glyph by strength.
173function signalGlyph(bars) {
174 var b = bars;
175 if (b < 0) b = 0;
176 if (b > 4) b = 4;
177 return WIFI_GLYPHS[b];
178}
180// securityLabel(sec) — human label for the security token.
181function securityLabel(sec) {
182 if (sec === "open") return "Open";
183 if (sec === "psk") return "WPA";
184 if (sec === "8021x") return "Enterprise";
185 return sec ? sec : "";
186}
188// networkId(ssid) — stable id (ssid itself; never empty).
189function networkId(ssid) {
190 var s = (ssid === undefined || ssid === null) ? "" : String(ssid);
191 return s.length > 0 ? s : "hidden-network";
192}
194if (typeof module !== 'undefined' && module.exports) {
195 module.exports = {
196 unwrap: unwrap,
197 prop: prop,
198 signalBars: signalBars,
199 parseManaged: parseManaged,
200 parseOrdered: parseOrdered,
201 networkRows: networkRows,
202 needsPassphrase: needsPassphrase,
203 signalRole: signalRole,
204 signalGlyph: signalGlyph,
205 securityLabel: securityLabel,
206 networkId: networkId
207 };
208}

quickshell/nuguland/network.test.js

Added
new file mode 100644

+112 / −0 text lines

1// network.test.js — node test for the pure network module (iwd D-Bus JSON
2// shaping). Run: node network.test.js (must print "network.test.js: ALL PASS")
3var assert = require('assert');
4var fs = require('fs');
5var path = require('path');
6var N = require('./network.js');
7
8var FIX = path.join(__dirname, 'test-fixtures', 'iwd');
9function fixture(name) { return fs.readFileSync(path.join(FIX, name), 'utf8'); }
11var passed = 0;
12function eq(got, want, msg) { assert.strictEqual(got, want, msg); passed++; }
13function ok(cond, msg) { assert(cond, msg); passed++; }
15var GMO = fixture('get-managed-objects.json');
16var GON = fixture('ordered-networks.json');
18// --- unwrap: peels busctl's { type, data: [value] } wrapper -----------------
19eq(N.unwrap('{"type":"u","data":[42]}'), 42, 'unwrap pulls the single payload');
20eq(N.unwrap('{"type":"a","data":[]}'), null, 'unwrap of empty data => null');
21eq(N.unwrap(null), null, 'unwrap(null) => null');
23// --- signalBars: dBm*100 -> 0..4 (thresholds match iwctl rendering) ---------
24eq(N.signalBars(-4900), 4, '-49 dBm => 4 bars');
25eq(N.signalBars(-6000), 4, '-60 dBm boundary => 4 bars');
26eq(N.signalBars(-6500), 3, '-65 dBm => 3 bars');
27eq(N.signalBars(-6800), 2, '-68 dBm => 2 bars');
28eq(N.signalBars(-8400), 1, '-84 dBm => 1 bar');
29eq(N.signalBars(-10000), 1, 'very weak => 1 bar (never 0 for a listed net)');
30eq(N.signalBars('not-a-number'), 0, 'non-finite => 0 bars');
32// --- parseManaged: GetManagedObjects -> structured -------------------------
33var managed = N.parseManaged(GMO);
34ok(/\/0\/4$/.test(managed.devicePath), 'devicePath is the station device object');
35eq(managed.device.name, 'wlan0', 'device name discovered (not hardcoded)');
36eq(managed.device.powered, true, 'device powered');
37eq(managed.device.mode, 'station', 'device mode station');
38eq(managed.station.state, 'connected', 'station state connected');
39eq(managed.station.scanning, false, 'station not scanning');
40ok(/686f6d652d77696669_psk$/.test(managed.station.connectedNetwork), 'connectedNetwork is home-wifi path');
41eq(Object.keys(managed.networks).length, 11, 'eleven networks in managed objects');
42ok('home-wifi' in managed.knownBySsid, 'home-wifi is a known network');
43ok('home-wifi-old' in managed.knownBySsid, 'home-wifi-old known (not currently in scan)');
44eq(Object.keys(managed.knownBySsid).length, 2, 'exactly two known networks');
46// --- parseOrdered: GetOrderedNetworks -> [{path,signal}] -------------------
47var ordered = N.parseOrdered(GON);
48eq(ordered.length, 11, 'eleven ordered networks');
49eq(ordered[0].signal, -6800, 'first ordered net signal = -6800 (connected first)');
50ok(/686f6d652d77696669_psk$/.test(ordered[0].path), 'first ordered path is home-wifi');
52// --- networkRows: join managed + ordered -> view rows ----------------------
53var rows = N.networkRows(managed, ordered);
54eq(rows.length, 11, 'eleven view rows');
55function row(ssid) { return rows.filter(function (r) { return r.ssid === ssid; })[0] || null; }
57var home = row('home-wifi');
58ok(home !== null, 'home-wifi present');
59eq(home.signal, 2, 'home-wifi 2 bars');
60eq(home.connected, true, 'home-wifi connected');
61eq(home.known, true, 'home-wifi known');
62eq(home.needsPassphrase, false, 'connected/known net needs no passphrase');
63ok(typeof home.path === 'string' && home.path.length > 0, 'row carries D-Bus object path');
65var fiveg = row('home-wifi-5g');
66eq(fiveg.signal, 4, 'home-wifi-5g 4 bars');
67eq(fiveg.known, false, 'home-wifi-5g not known');
68eq(fiveg.needsPassphrase, true, 'unknown psk net needs passphrase');
70var cafe = row('Cafe Guest WiFi');
71ok(cafe !== null, 'spaced SSID "Cafe Guest WiFi" preserved verbatim');
72eq(cafe.signal, 3, 'Cafe Guest WiFi 3 bars');
74var city = row('City Hotspot');
75ok(city !== null, 'open spaced SSID "City Hotspot" present');
76eq(city.security, 'open', 'City Hotspot is open');
77eq(city.needsPassphrase, false, 'open net needs no passphrase');
79eq(rows[0].ssid, 'home-wifi', 'iwd order preserved: connected network first');
81// --- robustness: malformed / empty inputs must NOT throw -------------------
82var emptyManaged = N.parseManaged('{"type":"a{oa{sa{sv}}}","data":[{}]}');
83eq(emptyManaged.devicePath, '', 'no device => empty devicePath');
84eq(emptyManaged.device, null, 'no device => null');
85eq(emptyManaged.station, null, 'no station => null');
86eq(Object.keys(emptyManaged.networks).length, 0, 'no networks => empty');
87eq(N.parseManaged(null).devicePath, '', 'parseManaged(null) safe');
88eq(N.parseOrdered(null).length, 0, 'parseOrdered(null) => []');
89eq(N.parseOrdered('{"type":"a(on)","data":[[]]}').length, 0, 'empty ordered => []');
90eq(N.networkRows({ networks: {} }, []).length, 0, 'no rows from empty inputs');
91// an ordered path with no matching managed network is skipped, not crashed
92eq(N.networkRows({ networks: {} }, [{ path: '/ghost', signal: -5000 }]).length, 0, 'orphan ordered path skipped');
94// --- view helpers ----------------------------------------------------------
95eq(N.signalRole(0), 'ui.minor', 'role weak');
96eq(N.signalRole(1), 'ui.minor', 'role 1 bar weak');
97eq(N.signalRole(2), 'ui.accent', 'role medium');
98eq(N.signalRole(3), 'ui.accent', 'role 3 medium');
99eq(N.signalRole(4), 'content.accent', 'role strong');
100eq(N.securityLabel('psk'), 'WPA', 'psk label');
101eq(N.securityLabel('open'), 'Open', 'open label');
102eq(N.securityLabel('8021x'), 'Enterprise', 'enterprise label');
103eq(N.needsPassphrase('open', false), false, 'open never needs passphrase');
104eq(N.needsPassphrase('psk', true), false, 'known psk needs no passphrase');
105eq(N.needsPassphrase('psk', false), true, 'unknown psk needs passphrase');
106eq(N.networkId('home-wifi'), 'home-wifi', 'networkId is the ssid');
107ok(N.networkId('').length > 0, 'networkId never empty');
108ok(N.signalGlyph(0).length > 0, 'glyph 0 non-empty');
109ok(N.signalGlyph(4).length > 0, 'glyph 4 non-empty');
111console.log(passed + ' assertions passed');
112console.log('network.test.js: ALL PASS');

quickshell/nuguland/shell.qml

Modified

+4 / −0 text lines

10061006 return network.stateJson();
1009 function networkSelfTest() : string {
1010 return network.selfTest();
1011 }
10091013 function networkWidgetState() : string {
10101014 const state = JSON.parse(network.stateJson());
10111015 state.barLabel = "network";

quickshell/nuguland/test-fixtures/iwctl/device-list-off.txt

Deleted
deleted file mode 100644

+0 / −6 text lines

1 Devices 
2--------------------------------------------------------------------------------
3 Name Address Powered Adapter Mode
4--------------------------------------------------------------------------------
5 wlan0 00:11:22:33:44:55 off phy0 station
6

quickshell/nuguland/test-fixtures/iwctl/device-list.txt

Deleted
deleted file mode 100644

+0 / −6 text lines

1 Devices 
2--------------------------------------------------------------------------------
3 Name Address Powered Adapter Mode
4--------------------------------------------------------------------------------
5 wlan0 00:11:22:33:44:55 on phy0 station
6

quickshell/nuguland/test-fixtures/iwctl/get-networks-empty.txt

Deleted
deleted file mode 100644

+0 / −5 text lines

1 Available networks 
2--------------------------------------------------------------------------------
3 Network name Security Signal
4--------------------------------------------------------------------------------
5

quickshell/nuguland/test-fixtures/iwctl/get-networks.txt

Deleted
deleted file mode 100644

+0 / −12 text lines

1 Available networks 
2--------------------------------------------------------------------------------
3 Network name Security Signal
4--------------------------------------------------------------------------------
5 >  home-wifi psk ****
6 home-wifi-5g psk ****
7 Cafe Guest WiFi open ****
8 City Hotspot open ****
9 Reading Room open ****
10 Neighbor 2G psk ****
11 skynet-guest psk ****

quickshell/nuguland/test-fixtures/iwctl/known-networks.txt

Deleted
deleted file mode 100644

+0 / −7 text lines

1 Known Networks 
2--------------------------------------------------------------------------------
3 Name Security Hidden Last connected
4--------------------------------------------------------------------------------
5 home-wifi-old psk Jun 8, 10:42 AM
6 home-wifi psk Jun 28, 6:12 PM
7

quickshell/nuguland/test-fixtures/iwctl/station-show-disconnected.txt

Deleted
deleted file mode 100644

+0 / −7 text lines

1 Station: wlan0 
2--------------------------------------------------------------------------------
3 Settable Property Value
4--------------------------------------------------------------------------------
5 Scanning no
6 State disconnected
7

quickshell/nuguland/test-fixtures/iwctl/station-show.txt

Deleted
deleted file mode 100644

+0 / −17 text lines

1 Station: wlan0 
2--------------------------------------------------------------------------------
3 Settable Property Value
4--------------------------------------------------------------------------------
5 Scanning no
6 State connected
7 Connected network home-wifi
8 IPv4 address 192.168.50.20
9 IPv6 address fd00:dead:beef:0:0011:22ff:fe33:4455
10 ConnectedBss 00:11:22:33:44:55
11 Frequency 2412
12 Channel 1
13 Security WPA2-Personal
14 RSSI -69 dBm
15 AverageRSSI -68 dBm
16 ConnectedTime 43160 s

quickshell/nuguland/test-fixtures/iwd/get-managed-objects.json

Added
new file mode 100644

+1 / −0 text lines

1{"type":"a{oa{sa{sv}}}","data":[{"/":{"org.freedesktop.DBus.ObjectManager":{}},"/net/connman/iwd":{"net.connman.iwd.Daemon":{},"org.freedesktop.DBus.Properties":{},"net.connman.iwd.AgentManager":{},"net.connman.iwd.p2p.ServiceManager":{}},"/net/connman/iwd/0":{"net.connman.iwd.Adapter":{"Powered":{"type":"b","data":true},"Model":{"type":"s","data":"Centrino Advanced-N 6205 [Taylor Peak] (Centrino Advanced-N 6205 (802.11a/b/g/n))"},"Vendor":{"type":"s","data":"Intel Corporation"},"Name":{"type":"s","data":"phy0"},"SupportedModes":{"type":"as","data":["ad-hoc","station","ap"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4":{"net.connman.iwd.Device":{"Name":{"type":"s","data":"wlan0"},"Address":{"type":"s","data":"00:aa:bb:cc:dd:04"},"Powered":{"type":"b","data":true},"Adapter":{"type":"o","data":"/net/connman/iwd/0"},"Mode":{"type":"s","data":"station"}},"org.freedesktop.DBus.Properties":{},"net.connman.iwd.Station":{"ConnectedNetwork":{"type":"o","data":"/net/connman/iwd/0/4/686f6d652d77696669_psk"},"ConnectedAccessPoint":{"type":"o","data":"/net/connman/iwd/0/4/686f6d652d77696669_psk/00aabbccdd05"},"Scanning":{"type":"b","data":false},"State":{"type":"s","data":"connected"},"Affinities":{"type":"ao","data":[]}},"net.connman.iwd.SimpleConfiguration":{},"net.connman.iwd.DeviceProvisioning":{"Started":{"type":"b","data":false}},"net.connman.iwd.SharedCodeDeviceProvisioning":{"Started":{"type":"b","data":false}},"net.connman.iwd.StationDiagnostic":{}},"/net/connman/iwd/0/4/6f322d53706f742d31323334_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"o2-Spot-1234"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/6f322d53706f742d31323334_psk/00aabbccdd03"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/6f322d53706f742d31323334_psk/00aabbccdd03":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:03"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/736b796e65742d6775657374_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"skynet-guest"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/736b796e65742d6775657374_psk/00aabbccdd00"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/736b796e65742d6775657374_psk/00aabbccdd00":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:00"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/4e65696768626f72203247_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"Neighbor 2G"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/4e65696768626f72203247_psk/00aabbccdd04"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/4e65696768626f72203247_psk/00aabbccdd04":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:05"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/636166652d636f726e6572_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"cafe-corner"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/636166652d636f726e6572_psk/00aabbccdd01"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/636166652d636f726e6572_psk/00aabbccdd01":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:01"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/52656164696e6720526f6f6d_open":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"Reading Room"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"open"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/52656164696e6720526f6f6d_open/00aabbccdd0a"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/52656164696e6720526f6f6d_open/00aabbccdd0a":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:0b"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/4369747920486f7473706f74_open":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"City Hotspot"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"open"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/4369747920486f7473706f74_open/00aabbccdd0b"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/4369747920486f7473706f74_open/00aabbccdd0b":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:0c"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/6f66666963652d77696669_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"office-wifi"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/6f66666963652d77696669_psk/00aabbccdd09"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/6f66666963652d77696669_psk/00aabbccdd09":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:0a"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/436166652047756573742057694669_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"Cafe Guest WiFi"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/436166652047756573742057694669_psk/00aabbccdd02"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/436166652047756573742057694669_psk/00aabbccdd02":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:02"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/686f6d652d776966692d3567_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"home-wifi-5g"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/686f6d652d776966692d3567_psk/00aabbccdd06"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/686f6d652d776966692d3567_psk/00aabbccdd06":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:07"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/67756573742d6e6574_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"guest-net"},"Connected":{"type":"b","data":false},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/67756573742d6e6574_psk/00aabbccdd07","/net/connman/iwd/0/4/67756573742d6e6574_psk/00aabbccdd08"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/67756573742d6e6574_psk/00aabbccdd08":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:09"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/67756573742d6e6574_psk/00aabbccdd07":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:08"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/686f6d652d77696669_psk":{"net.connman.iwd.Network":{"Name":{"type":"s","data":"home-wifi"},"Connected":{"type":"b","data":true},"Device":{"type":"o","data":"/net/connman/iwd/0/4"},"Type":{"type":"s","data":"psk"},"KnownNetwork":{"type":"o","data":"/net/connman/iwd/686f6d652d77696669_psk"},"ExtendedServiceSet":{"type":"ao","data":["/net/connman/iwd/0/4/686f6d652d77696669_psk/00aabbccdd05"]}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/0/4/686f6d652d77696669_psk/00aabbccdd05":{"net.connman.iwd.BasicServiceSet":{"Address":{"type":"s","data":"00:aa:bb:cc:dd:06"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/686f6d652d776966692d6f6c64_psk":{"net.connman.iwd.KnownNetwork":{"Name":{"type":"s","data":"home-wifi-old"},"Type":{"type":"s","data":"psk"},"Hidden":{"type":"b","data":false},"AutoConnect":{"type":"b","data":true},"LastConnectedTime":{"type":"s","data":"2025-06-08T09:42:27Z"}},"org.freedesktop.DBus.Properties":{}},"/net/connman/iwd/686f6d652d77696669_psk":{"net.connman.iwd.KnownNetwork":{"Name":{"type":"s","data":"home-wifi"},"Type":{"type":"s","data":"psk"},"Hidden":{"type":"b","data":false},"AutoConnect":{"type":"b","data":true},"LastConnectedTime":{"type":"s","data":"2026-06-28T17:12:44Z"}},"org.freedesktop.DBus.Properties":{}}}]}

quickshell/nuguland/test-fixtures/iwd/ordered-networks.json

Added
new file mode 100644

+1 / −0 text lines

1{"type":"a(on)","data":[[["/net/connman/iwd/0/4/686f6d652d77696669_psk",-6800],["/net/connman/iwd/0/4/686f6d652d776966692d3567_psk",-4900],["/net/connman/iwd/0/4/436166652047756573742057694669_psk",-6500],["/net/connman/iwd/0/4/67756573742d6e6574_psk",-6500],["/net/connman/iwd/0/4/4369747920486f7473706f74_open",-6600],["/net/connman/iwd/0/4/52656164696e6720526f6f6d_open",-6800],["/net/connman/iwd/0/4/4e65696768626f72203247_psk",-8400],["/net/connman/iwd/0/4/736b796e65742d6775657374_psk",-8600],["/net/connman/iwd/0/4/6f322d53706f742d31323334_psk",-8500],["/net/connman/iwd/0/4/6f66666963652d77696669_psk",-8500],["/net/connman/iwd/0/4/636166652d636f726e6572_psk",-8900]]]}