Ngrok: Add toggle to start/stop service manually

This commit is contained in:
Jason Wen 2024-04-11 05:05:37 +00:00
parent 2cbe1a7ec6
commit 957071fd42
1 changed files with 13 additions and 0 deletions

View File

@ -226,6 +226,19 @@ AdvancedNetworking::AdvancedNetworking(QWidget* parent, WifiManager* wifi): QWid
});
list->addItem(hiddenNetworkButton);
// Ngrok
QProcess process;
process.start("sudo service ngrok status | grep running");
process.waitForFinished();
QString output = QString(process.readAllStandardOutput());
bool ngrokRunning = !output.isEmpty();
ToggleControl *ngrokToggle = new ToggleControl(tr("Ngrok Service"), "", "", ngrokRunning);
connect(ngrokToggle, &ToggleControl::toggleFlipped, [=](bool state) {
if (state) std::system("sudo ngrok service start");
else std::system("sudo ngrok service stop");
});
list->addItem(ngrokToggle);
// Set initial config
wifi->updateGsmSettings(roamingEnabled, QString::fromStdString(params.get("GsmApn")), metered);