NetworkService: bugfix the interface could not longer be enabled or disabled.

This commit is contained in:
LemmyCook 2025-09-09 18:53:53 -04:00
parent b2d629e6a1
commit d089966249

View file

@ -96,6 +96,7 @@ Singleton {
function setWifiEnabled(enabled) {
Settings.data.network.wifiEnabled = enabled
wifiStateEnableProcess.running = true
}
function scan() {
@ -234,6 +235,8 @@ Singleton {
}
}
// Only check the state of the actual interface
// and update our setting to be in sync.
Process {
id: wifiStateProcess
running: false
@ -242,7 +245,7 @@ Singleton {
stdout: StdioCollector {
onStreamFinished: {
const enabled = text.trim() === "enabled"
Logger.log("Network", "Wi-Fi enabled:", enabled)
Logger.log("Network", "Wi-Fi adapter was detect as enabled:", enabled)
if (Settings.data.network.wifiEnabled !== enabled) {
Settings.data.network.wifiEnabled = enabled
}
@ -250,6 +253,30 @@ Singleton {
}
}
// Process to enable/disable the Wi-Fi interface
Process {
id: wifiStateEnableProcess
running: false
command: ["nmcli", "radio", "wifi", Settings.data.network.wifiEnabled ? "on" : "off"]
stdout: StdioCollector {
onStreamFinished: {
Logger.log("Network", "Wi-Fi state change command executed.")
// Re-check the state to ensure it's in sync
syncWifiState()
}
}
stderr: StdioCollector {
onStreamFinished: {
if (text.trim()) {
Logger.warn("Network", "Error changing Wi-Fi state: " + text)
}
}
}
}
// Helper process to get existing profiles
Process {
id: profileCheckProcess