Skip to content

Commit 43742c4

Browse files
committed
fix: field-exact network parse (AP-mode + disconnected); drop dead HA guards
Network.qml: parse "TYPE:STATE:CONNECTION" by exact fields instead of substring includes(). Fixes two issues: (1) the bar showed a wifi-connected icon while the device was a hotspot AP — now skipped when the connection is "Hotspot"; (2) includes("connected") also matched "disconnected", so a disconnected ethernet was mis-flagged as connected. Adds the CONNECTION field to the nmcli query. HomeAssistantPanel.qml: remove the dead in-function null guards in hasDetail/ iconFor — both are called only from the root?.-guarded sites with a required string arg, so entityId is never null; the real null risk (root during teardown) is handled at the call site.
1 parent 4f94f8b commit 43742c4

2 files changed

Lines changed: 21 additions & 20 deletions

File tree

quickshell/ii/modules/ii/sidebarLeft/homeAssistant/HomeAssistantPanel.qml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Item {
1616

1717
// Entities that have sub-controls worth an expand affordance.
1818
function hasDetail(entityId) {
19-
if (!entityId)
20-
return false; // delegate modelData is transiently null during Repeater construction
2119
const d = entityId.split(".")[0];
2220
if (d === "climate" || d === "media_player" || d === "fan" || d === "cover" || d === "vacuum")
2321
return true;
@@ -27,8 +25,6 @@ Item {
2725
}
2826

2927
function iconFor(entityId) {
30-
if (!entityId)
31-
return "help"; // delegate modelData is transiently null during Repeater construction
3228
const d = entityId.split(".")[0];
3329
switch (d) {
3430
case "light":

quickshell/ii/services/Network.qml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ Singleton {
265265

266266
Process {
267267
id: updateConnectionType
268-
command: ["sh", "-c", "nmcli -t -f TYPE,STATE d status && nmcli -t -f CONNECTIVITY g"]
268+
command: ["sh", "-c", "nmcli -t -f TYPE,STATE,CONNECTION d status && nmcli -t -f CONNECTIVITY g"]
269269
running: true
270270
// Re-trigger only restarts the process; StdioCollector below parses the FULL output
271271
// atomically on completion, so rapid nmcli-monitor events can't deliver a truncated
@@ -280,27 +280,32 @@ Singleton {
280280
let hasEthernet = false;
281281
let hasWifi = false;
282282
let wifiStatus = "disconnected";
283+
// Terse line: "TYPE:STATE:CONNECTION". Match fields EXACTLY — substring checks
284+
// mis-fire ("disconnected" contains "connected"; "wifi-p2p" contains "wifi").
283285
lines.forEach(line => {
284-
if (line.includes("ethernet") && line.includes("connected"))
286+
const parts = line.split(":");
287+
const type = parts[0];
288+
const state = parts[1] ?? "";
289+
const conn = parts.slice(2).join(":"); // connection name may contain ":"
290+
if (type === "ethernet" && state === "connected") {
285291
hasEthernet = true;
286-
else if (line.includes("wifi:")) {
287-
if (line.includes("disconnected")) {
288-
wifiStatus = "disconnected"
289-
}
290-
else if (line.includes("connected")) {
292+
} else if (type === "wifi") {
293+
if (conn === "Hotspot") {
294+
// Our own AP profile — the device is an access point, not a station
295+
// uplink, so don't report it as a Wi-Fi connection.
296+
} else if (state === "connected") {
291297
hasWifi = true;
292-
wifiStatus = "connected"
293-
298+
wifiStatus = "connected";
294299
if (connectivity === "limited") {
295300
hasWifi = false;
296-
wifiStatus = "limited"
301+
wifiStatus = "limited";
297302
}
298-
}
299-
else if (line.includes("connecting")) {
300-
wifiStatus = "connecting"
301-
}
302-
else if (line.includes("unavailable")) {
303-
wifiStatus = "disabled"
303+
} else if (state === "connecting") {
304+
wifiStatus = "connecting";
305+
} else if (state === "unavailable") {
306+
wifiStatus = "disabled";
307+
} else {
308+
wifiStatus = "disconnected";
304309
}
305310
}
306311
});

0 commit comments

Comments
 (0)