#include "windowmanager.h" #include #include #include namespace WindowManager { static QProcess wm; void ensureRunning() { wm.start(QLatin1String("openbox")); wm.closeReadChannel(QProcess::StandardError); wm.closeReadChannel(QProcess::StandardOutput); wm.closeWriteChannel(); wm.waitForStarted(1000); QTimer::singleShot(200, []() { if (wm.state() == QProcess::Running) { qDebug() << "- Spawned openbox"; } else if (wm.exitCode() == 0) { qDebug() << "- A WM is already running"; } else { qDebug() << "- openbox binary not in $PATH"; } }); } void stopOwnInstance() { if (wm.state() == QProcess::Running) { qDebug() << "- Politely terminating spawned WM"; wm.terminate(); QTimer::singleShot(1000, []() { if (wm.state() == QProcess::Running) { qDebug() << "- Forcefully killing spawned WM"; wm.kill(); } }); } } }