quickshell: fix network list flicker during refresh

Accumulate scan results into a temp array, swap to wifiNetworks
in one assignment when the process finishes. No more clearing
the list before each scan.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-26 19:41:40 +01:00
parent 917d983861
commit 8fe48557e4

View file

@ -641,6 +641,8 @@ in
onTriggered: netWidget.refreshNet() onTriggered: netWidget.refreshNet()
} }
property var _pendingNets: []
Process { Process {
id: wifiScanProc id: wifiScanProc
command: ["${pkgs.networkmanager}/bin/nmcli", "-t", "-f", "SSID,SIGNAL,SECURITY,IN-USE", "device", "wifi", "list", "--rescan", "auto"] command: ["${pkgs.networkmanager}/bin/nmcli", "-t", "-f", "SSID,SIGNAL,SECURITY,IN-USE", "device", "wifi", "list", "--rescan", "auto"]
@ -648,17 +650,21 @@ in
onRead: data => { onRead: data => {
let fields = data.split(":"); let fields = data.split(":");
if (fields.length < 4 || fields[0] === "") return; if (fields.length < 4 || fields[0] === "") return;
let nets = netWidget.wifiNetworks.slice(); for (let i = 0; i < netWidget._pendingNets.length; i++) {
for (let i = 0; i < nets.length; i++) { if (netWidget._pendingNets[i].ssid === fields[0]) return;
if (nets[i].ssid === fields[0]) return;
} }
nets.push({ netWidget._pendingNets.push({
ssid: fields[0], ssid: fields[0],
signal: parseInt(fields[1]) || 0, signal: parseInt(fields[1]) || 0,
security: fields[2], security: fields[2],
active: fields[3] === "*" active: fields[3] === "*"
}); });
netWidget.wifiNetworks = nets; }
}
onRunningChanged: {
if (!running) {
netWidget.wifiNetworks = netWidget._pendingNets;
netWidget._pendingNets = [];
} }
} }
} }
@ -683,7 +689,6 @@ in
function openNetDropdown() { function openNetDropdown() {
bar.toggleDropdown(netDropdown, function() { bar.toggleDropdown(netDropdown, function() {
netWidget.wifiNetworks = [];
wifiScanProc.running = true; wifiScanProc.running = true;
let pos = netWidget.mapToItem(bar.contentItem, netWidget.width / 2, 0); let pos = netWidget.mapToItem(bar.contentItem, netWidget.width / 2, 0);
netDropdown.dropdownX = pos.x; netDropdown.dropdownX = pos.x;