From d17b10fcc93407050d5d775fe1dcd0b411dc744f Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 25 Nov 2024 14:56:20 -0600 Subject: [PATCH] More robust output catching --- src/NetworkSettingsWidget.cpp | 36 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/NetworkSettingsWidget.cpp b/src/NetworkSettingsWidget.cpp index 26c23353..432ef910 100644 --- a/src/NetworkSettingsWidget.cpp +++ b/src/NetworkSettingsWidget.cpp @@ -340,22 +340,30 @@ void NetworkSettingsWidget::rebootBox() } void NetworkSettingsWidget::editWifiConnectionMode(int newMode) { - QProcess process; - QString command = QString("sed -i 's/^MODE.*/MODE %1/' /home/kipr/wombat-os/configFiles/wifiConnectionMode.txt").arg(newMode); - - process.start("bash", QStringList() << "-c" << command); - process.waitForFinished(); - - if (process.exitStatus() == QProcess::NormalExit) - { - qDebug() << "Successfully set MODE to:" << newMode; - } - else - { - qDebug() << "Failed to set MODE."; - } + QProcess process; + QString command = QString("sudo sed -i 's/^MODE.*/MODE %1/' /home/kipr/wombat-os/configFiles/wifiConnectionMode.txt").arg(newMode); + + // Start the process + process.start("bash", QStringList() << "-c" << command); + process.waitForFinished(); + + // Debug: Capture outputs + qDebug() << "Standard Output:" << process.readAllStandardOutput(); + qDebug() << "Error Output:" << process.readAllStandardError(); + + // Check for success + if (process.exitCode() == 0 && process.exitStatus() == QProcess::NormalExit) + { + qDebug() << "Successfully set MODE to:" << newMode; + } + else + { + qDebug() << "Failed to set MODE. Exit code:" << process.exitCode() + << "Exit status:" << process.exitStatus(); + } } + void NetworkSettingsWidget::indexChanged(int index) { NetworkManager::ref().turnOn();