Network/Wi-Fi: improvements

- Always check for ethernet status every 30s. Should not affect battery
life.
- Less aggressive scan intervals to give more times for slow adapters.
This commit is contained in:
LemmyCook 2025-09-06 16:11:16 -04:00
parent 1bb1015fdf
commit 86c6135def
2 changed files with 17 additions and 15 deletions

View file

@ -40,6 +40,6 @@ NIconButton {
return "signal_wifi_bad" return "signal_wifi_bad"
} }
} }
tooltipText: "Network / Wi-Fi." tooltipText: "Manage Wi-Fi."
onClicked: PanelService.getPanel("wifiPanel")?.toggle(screen, this) onClicked: PanelService.getPanel("wifiPanel")?.toggle(screen, this)
} }

View file

@ -54,7 +54,7 @@ Singleton {
Component.onCompleted: { Component.onCompleted: {
Logger.log("Network", "Service initialized") Logger.log("Network", "Service initialized")
syncWifiState() syncWifiState()
refresh() scan()
} }
// Save cache with debounce // Save cache with debounce
@ -75,6 +75,16 @@ Singleton {
onTriggered: scan() onTriggered: scan()
} }
// Ethernet check timer
// Always running every 30s
Timer {
id: ethernetCheckTimer
interval: 30000
running: true
repeat: true
onTriggered: ethernetStateProcess.running = true
}
// Core functions // Core functions
function syncWifiState() { function syncWifiState() {
wifiStateProcess.running = true wifiStateProcess.running = true
@ -87,14 +97,6 @@ Singleton {
wifiToggleProcess.running = true wifiToggleProcess.running = true
} }
function refresh() {
ethernetStateProcess.running = true
if (Settings.data.network.wifiEnabled) {
scan()
}
}
function scan() { function scan() {
if (scanning) if (scanning)
return return
@ -206,7 +208,7 @@ Singleton {
// Processes // Processes
Process { Process {
id: ethernetStateProcess id: ethernetStateProcess
running: false running: true
command: ["nmcli", "-t", "-f", "DEVICE,TYPE,STATE", "device"] command: ["nmcli", "-t", "-f", "DEVICE,TYPE,STATE", "device"]
stdout: StdioCollector { stdout: StdioCollector {
@ -408,7 +410,7 @@ Singleton {
Logger.log("Network", `Connected to network: "${connectProcess.ssid}"`) Logger.log("Network", `Connected to network: "${connectProcess.ssid}"`)
// Still do a scan to get accurate signal and security info // Still do a scan to get accurate signal and security info
delayedScanTimer.interval = 1000 delayedScanTimer.interval = 5000
delayedScanTimer.restart() delayedScanTimer.restart()
} }
} }
@ -522,8 +524,8 @@ Singleton {
root.forgettingNetwork = "" root.forgettingNetwork = ""
// Quick scan to verify the profile is gone // Scan to verify the profile is gone
delayedScanTimer.interval = 500 delayedScanTimer.interval = 5000
delayedScanTimer.restart() delayedScanTimer.restart()
} }
} }
@ -535,7 +537,7 @@ Singleton {
Logger.warn("Network", "Forget error: " + text) Logger.warn("Network", "Forget error: " + text)
} }
// Still Trigger a scan even on error // Still Trigger a scan even on error
delayedScanTimer.interval = 500 delayedScanTimer.interval = 1000
delayedScanTimer.restart() delayedScanTimer.restart()
} }
} }