Compare commits
1 Commits
main
...
shutdown-e
Author | SHA1 | Date |
---|---|---|
|
dcd2e6aded |
|
@ -70,6 +70,9 @@ int main(int argc, char *argv[])
|
||||||
QCommandLineOption stopRunning("stop-running", "Stop any running instances");
|
QCommandLineOption stopRunning("stop-running", "Stop any running instances");
|
||||||
parser.addOption(stopRunning);
|
parser.addOption(stopRunning);
|
||||||
|
|
||||||
|
QCommandLineOption terminateEnvironmentOnShutdown("terminate-environment-on-shutdown", "Terminate the desktop environment if the browser is shut down (i3 and sway supported)");
|
||||||
|
parser.addOption(terminateEnvironmentOnShutdown);
|
||||||
|
|
||||||
|
|
||||||
QCommandLineOption helpOption = parser.addHelpOption();
|
QCommandLineOption helpOption = parser.addHelpOption();
|
||||||
|
|
||||||
|
@ -137,6 +140,9 @@ int main(int argc, char *argv[])
|
||||||
options.setIgnoreSslErrors(true);
|
options.setIgnoreSslErrors(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(terminateEnvironmentOnShutdown)) {
|
||||||
|
options.setTerminateEnvironmentOnShutdown(true);
|
||||||
|
}
|
||||||
|
|
||||||
if ( positional.length() > 0) {
|
if ( positional.length() > 0) {
|
||||||
options.setUrl( positional[0 ] );
|
options.setUrl( positional[0 ] );
|
||||||
|
|
|
@ -202,6 +202,26 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
qInfo() << "Modo quiosco activado, ignorando intento de cerrar ventana";
|
qInfo() << "Modo quiosco activado, ignorando intento de cerrar ventana";
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OGCommandLineOptions &options = OGCommandLineOptions::getInstance();
|
||||||
|
|
||||||
|
if (options.getTerminateEnvironmentOnShutdown()) {
|
||||||
|
qInfo() << "Shutdown requested, will try to terminate the desktop environment now.";
|
||||||
|
auto swaysock = qgetenv("SWAYSOCK");
|
||||||
|
auto i3sock = qgetenv("I3SOCK");
|
||||||
|
|
||||||
|
if (swaysock.length() > 0) {
|
||||||
|
qInfo() << "We seem to be running Sway, sending termination command";
|
||||||
|
event->ignore();
|
||||||
|
m_shutdown_process.start("swaymsg", QStringList() << "exit");
|
||||||
|
} else if (i3sock.length() > 0) {
|
||||||
|
qInfo() << "We seem to be running i3, sending termination command";
|
||||||
|
event->ignore();
|
||||||
|
m_shutdown_process.start("i3-msg", QStringList() << "exit");
|
||||||
|
} else {
|
||||||
|
qInfo() << "Unknown environment running, can't stop it.";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,6 +308,8 @@ void MainWindow::commandQueued(const QString &command, bool confirm, bool return
|
||||||
connect(m_command.process, &QProcess::readyReadStandardOutput,this,&MainWindow::slotProcessOutput);
|
connect(m_command.process, &QProcess::readyReadStandardOutput,this,&MainWindow::slotProcessOutput);
|
||||||
connect(m_command.process, &QProcess::readyReadStandardError,this,&MainWindow::slotProcessErrorOutput);
|
connect(m_command.process, &QProcess::readyReadStandardError,this,&MainWindow::slotProcessErrorOutput);
|
||||||
|
|
||||||
|
connect(&m_shutdown_process, &QProcess::finished,this,&MainWindow::slotShutdownProcessFinished);
|
||||||
|
|
||||||
|
|
||||||
if(isAdmin()) {
|
if(isAdmin()) {
|
||||||
m_output->setTextColor(QColor(Qt::darkGreen));
|
m_output->setTextColor(QColor(Qt::darkGreen));
|
||||||
|
@ -471,6 +493,12 @@ void MainWindow::slotProcessError(QProcess::ProcessError error)
|
||||||
finishProgressBar();
|
finishProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slotShutdownProcessFinished(int code, QProcess::ExitStatus status) {
|
||||||
|
qInfo() << "Shutdown process finished with code" << code << "; status" << status;
|
||||||
|
qInfo() << "Now quitting.";
|
||||||
|
QCoreApplication::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::slotCreateTerminal()
|
void MainWindow::slotCreateTerminal()
|
||||||
{
|
{
|
||||||
QTermWidget* console = new QTermWidget(1,this);
|
QTermWidget* console = new QTermWidget(1,this);
|
||||||
|
|
|
@ -68,6 +68,9 @@ class MainWindow : public QMainWindow
|
||||||
void slotProcessOutput();
|
void slotProcessOutput();
|
||||||
void slotProcessErrorOutput();
|
void slotProcessErrorOutput();
|
||||||
|
|
||||||
|
void slotShutdownProcessFinished(int code, QProcess::ExitStatus status);
|
||||||
|
|
||||||
|
|
||||||
// Funcion para crear terminales
|
// Funcion para crear terminales
|
||||||
void slotCreateTerminal();
|
void slotCreateTerminal();
|
||||||
void slotDeleteTerminal();
|
void slotDeleteTerminal();
|
||||||
|
@ -112,6 +115,7 @@ class MainWindow : public QMainWindow
|
||||||
QLineEdit *m_webBar;
|
QLineEdit *m_webBar;
|
||||||
|
|
||||||
//QProcess *m_process;
|
//QProcess *m_process;
|
||||||
|
QProcess m_shutdown_process;
|
||||||
|
|
||||||
QMap<QString,QString> m_env;
|
QMap<QString,QString> m_env;
|
||||||
QFile *m_logfile;
|
QFile *m_logfile;
|
||||||
|
|
|
@ -38,6 +38,10 @@ class OGCommandLineOptions {
|
||||||
bool getIgnoreSslErrors() const { return _ignoreSslErrors; }
|
bool getIgnoreSslErrors() const { return _ignoreSslErrors; }
|
||||||
void setIgnoreSslErrors(bool value) { _ignoreSslErrors = value; }
|
void setIgnoreSslErrors(bool value) { _ignoreSslErrors = value; }
|
||||||
|
|
||||||
|
bool getTerminateEnvironmentOnShutdown() const { return _terminateEnvironmentOnShutdown; }
|
||||||
|
void setTerminateEnvironmentOnShutdown(bool value) { _terminateEnvironmentOnShutdown = value; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OGCommandLineOptions() {
|
OGCommandLineOptions() {
|
||||||
|
@ -48,4 +52,5 @@ private:
|
||||||
NewTabBehavior _newTabBehavior{ReplacePage};
|
NewTabBehavior _newTabBehavior{ReplacePage};
|
||||||
|
|
||||||
bool _ignoreSslErrors = false;
|
bool _ignoreSslErrors = false;
|
||||||
};
|
bool _terminateEnvironmentOnShutdown = false;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue