This commit is contained in:
concordia
2024-04-28 03:24:23 -05:00
parent 926a1b9f4a
commit 224327480a
35 changed files with 2117 additions and 1 deletions

BIN
system/clearpilot/tools/qt_shell Executable file

Binary file not shown.

View File

@@ -0,0 +1,76 @@
#include <QApplication>
#include <QWidget>
#include <QTextEdit>
#include <QProcess>
#include <QVBoxLayout>
#include <QFont>
#include <QScreen>
#include <QScrollBar>
#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#include <wayland-client-protocol.h>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
if (argc < 2) {
printf("Usage: %s '<command>'\n", argv[0]);
return 1;
}
QWidget window;
window.setWindowTitle("Shell Command Output Viewer");
window.setStyleSheet("background-color: black;");
window.showFullScreen();
auto windowHandle = window.windowHandle();
if (!windowHandle) {
fprintf(stderr, "Error: Unable to obtain window handle.\n");
return 1;
}
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
auto *s = static_cast<wl_surface*>(native->nativeResourceForWindow("surface", windowHandle));
if (!s) {
fprintf(stderr, "Error: Unable to obtain native Wayland surface.\n");
return 1;
}
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
wl_surface_commit(s);
window.setFixedSize(2160, 1080);
QVBoxLayout *layout = new QVBoxLayout(&window);
QTextEdit *outputDisplay = new QTextEdit;
outputDisplay->setFont(QFont("Consolas", 32));
outputDisplay->setReadOnly(true);
outputDisplay->setFixedSize(2160, 1080);
outputDisplay->setStyleSheet("color: white; background-color: black;");
outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar
layout->addWidget(outputDisplay);
QProcess process;
QObject::connect(&process, &QProcess::readyReadStandardOutput, [&]() {
static QStringList lines;
QString output = process.readAllStandardOutput();
lines += output.split("\n", QString::SkipEmptyParts);
while (lines.size() > 100) {
lines.removeFirst();
}
outputDisplay->setPlainText(lines.join("\n"));
outputDisplay->verticalScrollBar()->setValue(outputDisplay->verticalScrollBar()->maximum());
});
QObject::connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&]() {
app.quit();
});
QString command = argv[1];
process.start(QString("bash -c \"%1\"").arg(command));
return app.exec();
}

View File

@@ -1 +1 @@
sudo su comma -c "python3 shell.py \"echo hello; sleep 5\"
sudo su comma -c "python3 /data/openpilot/system/clearpilot/tools/shell.py \"echo hello; sleep 5\"