From 8fe48557e4ad6b8d16e08acbd17230e4f3bb31e3 Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 26 May 2026 19:41:40 +0100 Subject: [PATCH] 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 --- settings/hyprland.nix | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/settings/hyprland.nix b/settings/hyprland.nix index d7a64c5..1952097 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -641,6 +641,8 @@ in onTriggered: netWidget.refreshNet() } + property var _pendingNets: [] + Process { id: wifiScanProc command: ["${pkgs.networkmanager}/bin/nmcli", "-t", "-f", "SSID,SIGNAL,SECURITY,IN-USE", "device", "wifi", "list", "--rescan", "auto"] @@ -648,17 +650,21 @@ in onRead: data => { let fields = data.split(":"); if (fields.length < 4 || fields[0] === "") return; - let nets = netWidget.wifiNetworks.slice(); - for (let i = 0; i < nets.length; i++) { - if (nets[i].ssid === fields[0]) return; + for (let i = 0; i < netWidget._pendingNets.length; i++) { + if (netWidget._pendingNets[i].ssid === fields[0]) return; } - nets.push({ + netWidget._pendingNets.push({ ssid: fields[0], signal: parseInt(fields[1]) || 0, security: fields[2], active: fields[3] === "*" }); - netWidget.wifiNetworks = nets; + } + } + onRunningChanged: { + if (!running) { + netWidget.wifiNetworks = netWidget._pendingNets; + netWidget._pendingNets = []; } } } @@ -683,7 +689,6 @@ in function openNetDropdown() { bar.toggleDropdown(netDropdown, function() { - netWidget.wifiNetworks = []; wifiScanProc.running = true; let pos = netWidget.mapToItem(bar.contentItem, netWidget.width / 2, 0); netDropdown.dropdownX = pos.x;