repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(network): tap-to-expand row drawer with connection details + actions

56fc8e049152ebc2126dbd1cc1429d4824bb51ef

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Tapping a Wi-Fi row now opens an inline drawer instead of relying on a
per-row action button. The drawer shows signal (dBm, falling back to
bars) and security for every row, and for the CONNECTED network the
live StationDiagnostic detail — BSSID, band, channel, link rates and
mode — fetched lazily on expand. Contextual actions live in the drawer:
connect / disconnect / forget, or a passphrase field + join for a new
secured network.

Replaces the per-list capped Flickables (which clipped expansions, the
root cause of "expands but shows nothing") with ONE outer scroll pane
around the whole panel: the Wi-Fi list, an expanded drawer, and the
Bluetooth section all scroll together and nothing clips.

network.js gains pure, node-tested shaping: dbmFromCenti, bandLabel,
rateLabel (iwd's 100kbit/s units -> Mbps) and connectionDetail (shapes
the StationDiagnostic a{sv} reply; null when disconnected). Network.qml
adds a lazy diagnostics() read folded into connectionDetail and cleared
when nothing is connected. New networkDiagnostics IPC mirrors
networkState. signalDbm is now forwarded through buildModel.

SECURITY: the passphrase remains a transient TextInput value, passed as
a discrete connect() argument, never bound into state or logged. Test
fixtures use a synthetic BSSID; no real MAC is committed.

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

Changed files (5)

quickshell/nuguland/Network.qml

Modified
37 37 property var lastAction: ({
39 39 property int scanRetriesLeft: 0
40 + // StationDiagnostic.GetDiagnostics detail for the CONNECTED BSS only
41 + // (bssid/band/channel/rssi/rates/mode), fetched lazily on expand. {} = none.
42 + property var connectionDetail: ({
43 + })
41 45 // Emitted whenever the model is recomputed after an async read. The view
42 46 // connects to this to re-pull stateJson().
48 52 readonly property string ifaceDevice: "net.connman.iwd.Device"
49 53 readonly property string ifaceNetwork: "net.connman.iwd.Network"
50 54 readonly property string ifaceKnown: "net.connman.iwd.KnownNetwork"
55 + readonly property string ifaceDiag: "net.connman.iwd.StationDiagnostic"
52 57 function busctlCall(objectPath, iface, method) {
53 58 return ["busctl", "--json=short", "call", svc, objectPath, iface, method];
99 104 "security": n.security,
100 105 "securityLabel": Network.securityLabel(n.security),
101 106 "signal": n.signal,
107 + "signalDbm": n.signalDbm,
102 108 "signalPercent": n.signal * 25,
103 109 "signalRole": Network.signalRole(n.signal),
104 110 "signalGlyph": Network.signalGlyph(n.signal),
112 118 mergedModel = out;
119 + // Drop stale per-BSS detail if nothing is connected anymore.
120 + var stillConnected = false;
121 + for (var j = 0; j < out.length; j++) if (out[j].connected) stillConnected = true;
122 + if (!stillConnected)
123 + connectionDetail = ({});
113 124 refreshed();
124 135 "enabled": wifiEnabled
126 137 "active": active,
138 + "connectionDetail": connectionDetail,
127 139 "networks": mergedModel,
128 140 "knownNetworks": mergedModel,
129 141 "compact": {
255 267 check("signalGlyph(0) non-empty", Network.signalGlyph(0).length > 0, true);
256 268 check("parseManaged(null) safe", Network.parseManaged(null).devicePath, "");
270 + // connectionDetail (StationDiagnostic) — synthetic, sanitized BSSID.
271 + var diag = JSON.stringify({ "type": "a{sv}", "data": [{
272 + "ConnectedBss": { "type": "s", "data": "00:aa:bb:cc:dd:01" },
273 + "Frequency": { "type": "u", "data": 5220 },
274 + "Channel": { "type": "q", "data": 44 },
275 + "RSSI": { "type": "n", "data": -65 },
276 + "RxMode": { "type": "s", "data": "802.11n" },
277 + "TxBitrate": { "type": "u", "data": 1080 },
278 + "RxBitrate": { "type": "u", "data": 1350 }
279 + }] });
280 + var det = Network.connectionDetail(diag);
281 + check("connectionDetail band", det.band, "5 GHz");
282 + check("connectionDetail channel", det.channel, 44);
283 + check("connectionDetail rxRate", det.rxRate, "135 Mbps");
284 + check("connectionDetail rssi", det.rssi, -65);
285 + check("connectionDetail disconnected null", Network.connectionDetail('{"type":"a{sv}","data":[{}]}'), null);
286 + check("dbmFromCenti", Network.dbmFromCenti(-6500), -65);
258 288 return JSON.stringify({
259 289 "pass": pass,
260 290 "fail": fail,
355 385 return stateJson();
388 + // diagnostics() — lazy fetch of the connected BSS detail. The view calls
389 + // this when the connected row is expanded; diagProc.onStreamFinished folds
390 + // the result into connectionDetail and emits refreshed() so the drawer fills.
391 + function diagnostics() {
392 + if (devicePath && activeRow())
393 + diagProc.exec(busctlCall(devicePath, ifaceDiag, "GetDiagnostics"));
395 + return stateJson();
358 398 function checkConnectivity() {
359 399 lastAction = {
360 400 "kind": "check-connectivity"
455 + // Lazy StationDiagnostic read (connected BSS only). On reply, shape via
456 + // network.js#connectionDetail and emit refreshed() so the open drawer fills.
457 + Process {
458 + id: diagProc
460 + running: false
462 + stdout: StdioCollector {
463 + waitForEnd: true
464 + onStreamFinished: {
465 + root.connectionDetail = Network.connectionDetail(this.text) || ({});
466 + root.refreshed();
415 472 // --- action Processes --------------------------------------------------
417 474 Process {

quickshell/nuguland/PopoutHost.qml

Modified
2735 + function disconnectNetwork() {
2736 + if (networkService)
2737 + refreshNetwork(networkService.disconnect());
2741 + // Toggle a row's detail drawer. Opening the CONNECTED row triggers a
2742 + // lazy StationDiagnostic read (bssid/band/rate) that fills in async.
2743 + function expandRow(row) {
2744 + const willOpen = expandedSsid !== row.ssid;
2745 + expandedSsid = willOpen ? row.ssid : "";
2746 + if (willOpen && row.connected && networkService)
2747 + refreshNetwork(networkService.diagnostics());
2735 2751 function toggleBluetooth() {
2736 2752 if (bluetoothService)
2737 2753 refreshBluetooth(bluetoothService.toggle(!(bluetoothState.adapter && bluetoothState.adapter.state === "powered")));
2804 + // One scroll pane for the whole panel: a long Wi-Fi scan + the
2805 + // Bluetooth list scroll together, and an expanded row's detail drawer
2806 + // grows inside it without clipping. Idle (no overflow) => not interactive.
2807 + Flickable {
2808 + width: parent.width
2809 + height: root.height
2810 + contentWidth: width
2811 + contentHeight: panelCol.height
2812 + clip: true
2813 + interactive: contentHeight > height
2814 + boundsBehavior: Flickable.StopAtBounds
2815 + flickableDirection: Flickable.VerticalFlick
2817 + Column {
2818 + id: panelCol
2820 + width: parent.width
2821 + spacing: 10
2789 2824 objectName: "networkRateRow"
2790 2825 width: parent.width
2869 - // Cap the network list so a long scan scrolls internally instead
2870 - // of pushing the Bluetooth section off the bottom of the popup.
2871 - Flickable {
2904 + Column {
2872 2905 width: parent.width
2873 - height: Math.min(wifiListCol.height, 232)
2874 - contentHeight: wifiListCol.height
2875 - clip: true
2876 - interactive: contentHeight > height
2877 - boundsBehavior: Flickable.StopAtBounds
2906 + spacing: 6
2879 - Column {
2880 - id: wifiListCol
2908 + Repeater {
2909 + model: root.networkState.networks || []
2882 - width: parent.width
2883 - spacing: 6
2911 + delegate: Column {
2912 + id: wifiRow
2885 - Repeater {
2886 - model: root.networkState.networks || []
2914 + required property var modelData
2915 + readonly property bool active: modelData.connected === true
2916 + readonly property bool revealed: root.expandedSsid === modelData.ssid
2917 + readonly property var detail: root.networkState.connectionDetail || ({})
2888 - delegate: Column {
2889 - id: wifiRow
2891 - required property var modelData
2892 - readonly property bool active: modelData.connected === true
2893 - readonly property bool revealed: root.expandedSsid === modelData.ssid
2895 - width: root.width
2896 - spacing: 4
2919 + width: parent.width
2920 + spacing: 4
2898 2922 // --- washout-fixed card: solid dark base, identity via thin
2899 - // accent bar + border; signal colour on bar + glyph, not fill.
2923 + // accent bar + border; whole card taps to open its drawer.
2900 2924 Rectangle {
2901 2925 width: parent.width
2902 2926 height: 40
2903 2927 radius: 12
2904 2928 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, wifiRow.active ? 0.82 : 0.55) : "#333333"
2905 - border.width: wifiRow.active ? 2 : 1
2906 - 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"
2929 + border.width: (wifiRow.active || wifiRow.revealed) ? 2 : 1
2930 + border.color: root.theme ? (wifiRow.active ? root.theme.ui.accent : (wifiRow.modelData.state === "connecting" ? root.roleColor("warning") : (wifiRow.revealed ? root.theme.withAlpha(root.theme.ui.accent, 0.6) : root.theme.withAlpha(root.theme.ui.minor, 0.45)))) : "white"
2908 2932 // left accent bar — only on the connected network
2909 2933 Rectangle {
2929 2953 color: root.roleColor(wifiRow.modelData.signalRole || "ui.minor")
2932 - Rectangle {
2933 - id: wifiAction
2956 + // chevron hints the row expands; rotates when open
2957 + Text {
2958 + id: wifiChevron
2935 2960 anchors.right: parent.right
2936 - anchors.rightMargin: 10
2961 + anchors.rightMargin: 12
2937 2962 anchors.verticalCenter: parent.verticalCenter
2938 - width: 66
2939 - height: 26
2940 - radius: 9
2941 - color: root.theme ? root.theme.withAlpha(wifiRow.active ? root.theme.error : root.theme.ui.accent, wifiRow.revealed ? 0.34 : 0.18) : "transparent"
2942 - border.width: 1
2943 - border.color: root.theme ? root.theme.withAlpha(wifiRow.active ? root.theme.error : root.theme.ui.accent, 0.7) : "white"
2945 - NuguText {
2946 - anchors.centerIn: parent
2947 - theme: root.theme
2948 - variant: "meta"
2949 - text: wifiRow.active ? "forget" : (wifiRow.modelData.needsPassphrase ? (wifiRow.revealed ? "cancel" : "connect") : "connect")
2952 - MouseArea {
2953 - anchors.fill: parent
2954 - onClicked: {
2955 - if (wifiRow.active) {
2956 - root.expandedSsid = "";
2957 - root.forgetNetwork(wifiRow.modelData.id);
2958 - } else if (wifiRow.modelData.needsPassphrase) {
2959 - root.expandedSsid = wifiRow.revealed ? "" : wifiRow.modelData.ssid;
2960 - } else {
2961 - root.expandedSsid = "";
2962 - root.selectNetwork(wifiRow.modelData.id);
2963 + font.family: "Symbols Nerd Font Mono"
2964 + font.pixelSize: 16
2965 + text: ""
2966 + rotation: wifiRow.revealed ? 90 : 0
2967 + color: root.roleColor(wifiRow.active ? "content.accent" : "ui.minor")
2969 2970 NuguText {
2970 2971 id: wifiLabel
2972 - anchors.right: wifiAction.left
2973 + anchors.right: wifiChevron.left
2973 2974 anchors.rightMargin: 10
2974 2975 anchors.verticalCenter: parent.verticalCenter
2975 2976 theme: root.theme
2989 2990 elide: Text.ElideRight
2993 + MouseArea {
2994 + anchors.fill: parent
2995 + onClicked: root.expandRow(wifiRow.modelData)
2994 - // --- inline passphrase entry for a NEW secured network.
2995 - // echoMode Password; text lives only here, cleared on submit,
2996 - // never bound into networkState / any serialized property.
3000 + // --- detail + actions drawer (revealed on tap) -----------
2997 3001 Rectangle {
2998 - id: wifiPpRow
3000 - function submit() {
3001 - root.connectSecured(wifiRow.modelData.ssid, wifiPp.text);
3002 - wifiPp.text = "";
3003 - root.expandedSsid = "";
3002 + id: wifiDrawer
3006 3004 visible: wifiRow.revealed
3007 3005 width: parent.width
3008 - height: visible ? 34 : 0
3006 + height: visible ? drawerCol.height + 16 : 0
3009 3007 radius: 10
3010 - color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.7) : "#333333"
3008 + color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.55) : "#333333"
3011 3009 border.width: 1
3012 - border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.6) : "white"
3013 - onVisibleChanged: {
3014 - if (visible)
3015 - Qt.callLater(function() {
3016 - wifiPp.forceActiveFocus();
3017 - });
3010 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.4) : "white"
3011 + clip: true
3020 - TextInput {
3021 - id: wifiPp
3013 + Column {
3014 + id: drawerCol
3023 - anchors.left: parent.left
3024 - anchors.leftMargin: 12
3025 - anchors.right: wifiPpConfirm.left
3026 - anchors.rightMargin: 10
3027 - anchors.verticalCenter: parent.verticalCenter
3028 - verticalAlignment: TextInput.AlignVCenter
3029 - color: root.theme ? root.theme.content.normal : "white"
3030 - selectionColor: root.theme ? root.theme.ui.focus : "#ffffff"
3031 - selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
3032 - font.family: "IBM Plex Sans"
3033 - font.pixelSize: 13
3034 - echoMode: TextInput.Password
3035 - clip: true
3036 - onAccepted: wifiPpRow.submit()
3037 - Keys.onReturnPressed: (event) => {
3038 - event.accepted = true;
3039 - wifiPpRow.submit();
3041 - Keys.onEnterPressed: (event) => {
3042 - event.accepted = true;
3043 - wifiPpRow.submit();
3045 - Keys.onEscapePressed: (event) => {
3046 - event.accepted = true;
3047 - wifiPp.text = "";
3048 - root.expandedSsid = "";
3052 - NuguText {
3053 - anchors.left: parent.left
3054 - anchors.leftMargin: 12
3055 - anchors.verticalCenter: parent.verticalCenter
3056 - visible: wifiPp.text.length === 0
3057 - theme: root.theme
3058 - variant: "meta"
3059 - text: "passphrase"
3060 - opacity: 0.7
3063 - Rectangle {
3064 - id: wifiPpConfirm
3066 - anchors.right: parent.right
3067 - anchors.rightMargin: 6
3068 - anchors.verticalCenter: parent.verticalCenter
3069 - width: 56
3070 - height: 24
3071 - radius: 8
3072 - color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.22) : "transparent"
3073 - border.width: 1
3074 - border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.7) : "white"
3016 + x: 12
3017 + y: 8
3018 + width: parent.width - 24
3019 + spacing: 6
3021 + // signal + security — available for every row
3076 3022 NuguText {
3077 - anchors.centerIn: parent
3078 3023 theme: root.theme
3079 3024 variant: "meta"
3080 - text: "join"
3025 + text: {
3026 + const dbm = wifiRow.modelData.signalDbm;
3027 + const sig = (dbm === null || dbm === undefined) ? `${wifiRow.modelData.signal}/4 bars` : `${dbm} dBm`;
3028 + return `${wifiRow.modelData.securityLabel || "Open"} · ${sig}`;
3030 + color: root.theme ? root.theme.content.normal : "white"
3083 - MouseArea {
3084 - anchors.fill: parent
3085 - onClicked: wifiPpRow.submit()
3033 + // connected-only BSS detail (StationDiagnostic)
3034 + Column {
3035 + visible: wifiRow.active && !!wifiRow.detail.bssid
3036 + width: parent.width
3037 + spacing: 2
3039 + NuguText {
3040 + theme: root.theme
3041 + variant: "meta"
3042 + text: `${wifiRow.detail.band || "?"}${wifiRow.detail.channel ? " · ch " + wifiRow.detail.channel : ""}${wifiRow.detail.mode ? " · " + wifiRow.detail.mode : ""}`
3043 + opacity: 0.8
3046 + NuguText {
3047 + theme: root.theme
3048 + variant: "meta"
3049 + visible: !!wifiRow.detail.rxRate || !!wifiRow.detail.txRate
3050 + text: `↓ ${wifiRow.detail.rxRate || "?"} ↑ ${wifiRow.detail.txRate || "?"}`
3051 + opacity: 0.8
3054 + NuguText {
3055 + theme: root.theme
3056 + variant: "meta"
3057 + text: wifiRow.detail.bssid
3058 + opacity: 0.6
3063 + // action pills — hidden when a passphrase is needed
3064 + Row {
3065 + visible: !wifiRow.modelData.needsPassphrase
3066 + spacing: 8
3068 + Rectangle {
3069 + visible: !wifiRow.active
3070 + width: 96
3071 + height: 28
3072 + radius: 9
3073 + color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.18) : "transparent"
3074 + border.width: 1
3075 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.7) : "white"
3077 + NuguText {
3078 + anchors.centerIn: parent
3079 + theme: root.theme
3080 + variant: "meta"
3081 + text: "connect"
3084 + MouseArea {
3085 + anchors.fill: parent
3086 + onClicked: {
3087 + root.expandedSsid = "";
3088 + root.selectNetwork(wifiRow.modelData.id);
3094 + Rectangle {
3095 + visible: wifiRow.active
3096 + width: 96
3097 + height: 28
3098 + radius: 9
3099 + color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.18) : "transparent"
3100 + border.width: 1
3101 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.7) : "white"
3103 + NuguText {
3104 + anchors.centerIn: parent
3105 + theme: root.theme
3106 + variant: "meta"
3107 + text: "disconnect"
3110 + MouseArea {
3111 + anchors.fill: parent
3112 + onClicked: {
3113 + root.expandedSsid = "";
3114 + root.disconnectNetwork();
3120 + Rectangle {
3121 + visible: wifiRow.active || wifiRow.modelData.known
3122 + width: 96
3123 + height: 28
3124 + radius: 9
3125 + color: root.theme ? root.theme.withAlpha(root.theme.error, 0.18) : "transparent"
3126 + border.width: 1
3127 + border.color: root.theme ? root.theme.withAlpha(root.theme.error, 0.7) : "white"
3129 + NuguText {
3130 + anchors.centerIn: parent
3131 + theme: root.theme
3132 + variant: "meta"
3133 + text: "forget"
3136 + MouseArea {
3137 + anchors.fill: parent
3138 + onClicked: {
3139 + root.expandedSsid = "";
3140 + root.forgetNetwork(wifiRow.modelData.id);
3148 + // --- inline passphrase entry for a NEW secured network.
3149 + // echoMode Password; text lives only here, cleared on
3150 + // submit, never bound into networkState / any logged field.
3151 + Rectangle {
3152 + id: wifiPpRow
3154 + function submit() {
3155 + root.connectSecured(wifiRow.modelData.ssid, wifiPp.text);
3156 + wifiPp.text = "";
3157 + root.expandedSsid = "";
3160 + visible: wifiRow.modelData.needsPassphrase
3161 + width: parent.width
3162 + height: visible ? 34 : 0
3163 + radius: 10
3164 + color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.7) : "#333333"
3165 + border.width: 1
3166 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.6) : "white"
3167 + onVisibleChanged: {
3168 + if (visible && wifiRow.revealed)
3169 + Qt.callLater(function() {
3170 + wifiPp.forceActiveFocus();
3171 + });
3174 + TextInput {
3175 + id: wifiPp
3177 + anchors.left: parent.left
3178 + anchors.leftMargin: 12
3179 + anchors.right: wifiPpConfirm.left
3180 + anchors.rightMargin: 10
3181 + anchors.verticalCenter: parent.verticalCenter
3182 + verticalAlignment: TextInput.AlignVCenter
3183 + color: root.theme ? root.theme.content.normal : "white"
3184 + selectionColor: root.theme ? root.theme.ui.focus : "#ffffff"
3185 + selectedTextColor: root.theme ? root.theme.content.backdrop : "black"
3186 + font.family: "IBM Plex Sans"
3187 + font.pixelSize: 13
3188 + echoMode: TextInput.Password
3189 + clip: true
3190 + onAccepted: wifiPpRow.submit()
3191 + Keys.onReturnPressed: (event) => {
3192 + event.accepted = true;
3193 + wifiPpRow.submit();
3195 + Keys.onEnterPressed: (event) => {
3196 + event.accepted = true;
3197 + wifiPpRow.submit();
3199 + Keys.onEscapePressed: (event) => {
3200 + event.accepted = true;
3201 + wifiPp.text = "";
3202 + root.expandedSsid = "";
3206 + NuguText {
3207 + anchors.left: parent.left
3208 + anchors.leftMargin: 12
3209 + anchors.verticalCenter: parent.verticalCenter
3210 + visible: wifiPp.text.length === 0
3211 + theme: root.theme
3212 + variant: "meta"
3213 + text: "passphrase"
3214 + opacity: 0.7
3217 + Rectangle {
3218 + id: wifiPpConfirm
3220 + anchors.right: parent.right
3221 + anchors.rightMargin: 6
3222 + anchors.verticalCenter: parent.verticalCenter
3223 + width: 56
3224 + height: 24
3225 + radius: 8
3226 + color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.22) : "transparent"
3227 + border.width: 1
3228 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.7) : "white"
3230 + NuguText {
3231 + anchors.centerIn: parent
3232 + theme: root.theme
3233 + variant: "meta"
3234 + text: "join"
3237 + MouseArea {
3238 + anchors.fill: parent
3239 + onClicked: wifiPpRow.submit()
3178 - Flickable {
3334 + Column {
3179 3335 width: parent.width
3180 - height: Math.min(btListCol.height, 184)
3181 - contentHeight: btListCol.height
3182 - clip: true
3183 - interactive: contentHeight > height
3184 - boundsBehavior: Flickable.StopAtBounds
3336 + spacing: 6
3186 - Column {
3187 - id: btListCol
3338 + Repeater {
3339 + model: root.bluetoothState.devices || []
3189 - width: parent.width
3190 - spacing: 6
3192 - Repeater {
3193 - model: root.bluetoothState.devices || []
3195 - delegate: Rectangle {
3341 + delegate: Rectangle {
3196 3342 id: deviceRow
3198 3344 required property var modelData
3252 3400 component TrayPanel: Column {

quickshell/nuguland/network.js

Modified
41 41 return 1;
44 +// dbmFromCenti(centiDbm) — iwd's dBm*100 -> rounded dBm. Non-finite => null.
45 +function dbmFromCenti(centiDbm) {
46 + var v = Number(centiDbm);
47 + if (!isFinite(v)) return null;
48 + return Math.round(v / 100);
44 51 // --- Parsers (JSON -> plain data) ------------------------------------------
46 53 // parseManaged(rawGmo) -> {
131 138 ssid: n.ssid,
132 139 security: n.security,
133 140 signal: signalBars(o.signal),
141 + signalDbm: dbmFromCenti(o.signal),
134 142 connected: n.connected,
135 143 known: n.known,
136 144 needsPassphrase: needsPassphrase(n.security, n.known),
191 199 return s.length > 0 ? s : "hidden-network";
202 +// --- Connection detail (StationDiagnostic.GetDiagnostics) ------------------
203 +// Only the CONNECTED network has these; iwd exposes no per-BSS detail for
204 +// other scanned networks. The expand drawer shows bars/security for any row
205 +// and these extra fields only for the connected one.
207 +// bandLabel(freqMHz) — Wi-Fi band from centre frequency. "" if unknown.
208 +function bandLabel(freqMHz) {
209 + var f = Number(freqMHz);
210 + if (!isFinite(f) || f <= 0) return "";
211 + if (f >= 5925) return "6 GHz";
212 + if (f >= 4900) return "5 GHz";
213 + if (f >= 2400) return "2.4 GHz";
214 + return "";
217 +// rateLabel(raw) — iwd Rx/TxBitrate is in units of 100 kbit/s. -> "135 Mbps".
218 +// "" for missing/zero so the view can omit it.
219 +function rateLabel(raw) {
220 + var v = Number(raw);
221 + if (!isFinite(v) || v <= 0) return "";
222 + return Math.round(v / 10) + " Mbps";
225 +// connectionDetail(rawDiag) -> { bssid, band, channel, rssi, rxRate, txRate,
226 +// mode } | null. rawDiag is the StationDiagnostic.GetDiagnostics a{sv} reply.
227 +// Returns null when there is no connected BSS (disconnected / no diagnostics).
228 +function connectionDetail(rawDiag) {
229 + var d = unwrap(rawDiag);
230 + if (!d || typeof d !== "object") return null;
231 + var bssid = prop(d, "ConnectedBss", "");
232 + if (!bssid) return null;
233 + return {
234 + bssid: String(bssid),
235 + band: bandLabel(prop(d, "Frequency", 0)),
236 + channel: Number(prop(d, "Channel", 0)) || null,
237 + rssi: Number(prop(d, "RSSI", 0)) || null,
238 + rxRate: rateLabel(prop(d, "RxBitrate", 0)),
239 + txRate: rateLabel(prop(d, "TxBitrate", 0)),
240 + mode: String(prop(d, "RxMode", "") || "")
241 + };
194 244 if (typeof module !== 'undefined' && module.exports) {
195 245 module.exports = {
196 246 unwrap: unwrap,
197 247 prop: prop,
198 248 signalBars: signalBars,
249 + dbmFromCenti: dbmFromCenti,
199 250 parseManaged: parseManaged,
200 251 parseOrdered: parseOrdered,
201 252 networkRows: networkRows,
203 254 signalRole: signalRole,
204 255 signalGlyph: signalGlyph,
205 256 securityLabel: securityLabel,
206 - networkId: networkId
257 + networkId: networkId,
258 + bandLabel: bandLabel,
259 + rateLabel: rateLabel,
260 + connectionDetail: connectionDetail

quickshell/nuguland/network.test.js

Modified
108 108 ok(N.signalGlyph(0).length > 0, 'glyph 0 non-empty');
109 109 ok(N.signalGlyph(4).length > 0, 'glyph 4 non-empty');
111 +// --- dbmFromCenti + signalDbm on rows --------------------------------------
112 +eq(N.dbmFromCenti(-6500), -65, 'centiDbm -> dBm');
113 +eq(N.dbmFromCenti(-6849), -68, 'centiDbm rounds');
114 +eq(N.dbmFromCenti('x'), null, 'non-finite => null');
115 +eq(home.signalDbm, -68, 'home-wifi row carries dBm (-6800 -> -68)');
116 +ok(typeof fiveg.signalDbm === 'number' && fiveg.signalDbm < 0, 'fiveg signalDbm is a negative dBm number');
118 +// --- bandLabel / rateLabel -------------------------------------------------
119 +eq(N.bandLabel(5220), '5 GHz', '5220 MHz => 5 GHz');
120 +eq(N.bandLabel(2412), '2.4 GHz', '2412 MHz => 2.4 GHz');
121 +eq(N.bandLabel(6195), '6 GHz', '6195 MHz => 6 GHz');
122 +eq(N.bandLabel(0), '', 'zero freq => empty');
123 +eq(N.rateLabel(1350), '135 Mbps', '1350 (100kbit/s) => 135 Mbps');
124 +eq(N.rateLabel(1080), '108 Mbps', '1080 => 108 Mbps');
125 +eq(N.rateLabel(0), '', 'zero rate => empty');
127 +// --- connectionDetail: StationDiagnostic a{sv} (synthetic, sanitized BSSID) -
128 +var DIAG = JSON.stringify({ type: 'a{sv}', data: [{
129 + ConnectedBss: { type: 's', data: '00:aa:bb:cc:dd:01' },
130 + Frequency: { type: 'u', data: 5220 },
131 + Channel: { type: 'q', data: 44 },
132 + Security: { type: 's', data: 'WPA2-Personal' },
133 + RSSI: { type: 'n', data: -65 },
134 + AverageRSSI: { type: 'n', data: -66 },
135 + RxMode: { type: 's', data: '802.11n' },
136 + TxBitrate: { type: 'u', data: 1080 },
137 + RxBitrate: { type: 'u', data: 1350 }
138 +}] });
139 +var det = N.connectionDetail(DIAG);
140 +ok(det !== null, 'connectionDetail returns an object for a connected BSS');
141 +eq(det.bssid, '00:aa:bb:cc:dd:01', 'bssid carried verbatim');
142 +eq(det.band, '5 GHz', 'band derived from frequency');
143 +eq(det.channel, 44, 'channel carried');
144 +eq(det.rssi, -65, 'rssi is plain dBm (not centi)');
145 +eq(det.rxRate, '135 Mbps', 'rx rate converted');
146 +eq(det.txRate, '108 Mbps', 'tx rate converted');
147 +eq(det.mode, '802.11n', 'mode carried');
148 +eq(N.connectionDetail(null), null, 'no diag => null');
149 +eq(N.connectionDetail('{"type":"a{sv}","data":[{}]}'), null, 'no ConnectedBss => null (disconnected)');
111 151 console.log(passed + ' assertions passed');
112 152 console.log('network.test.js: ALL PASS');

quickshell/nuguland/shell.qml

Modified
1010 1010 return network.selfTest();
1013 + function networkDiagnostics() : string {
1014 + return network.diagnostics();
1013 1017 function networkWidgetState() : string {
1014 1018 const state = JSON.parse(network.stateJson());
1015 1019 state.barLabel = "network";