From 3d56e593a68cc7b1f60a9a95277f3885b744bc2c Mon Sep 17 00:00:00 2001 From: acetone Date: Fri, 11 Feb 2022 03:50:27 -0500 Subject: [PATCH] fix for start to non-gui system (QApplication) --- main.cpp | 7 ++++++- systemd/ircabot.service | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 0d00073..1dc5f73 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,12 @@ int main(int argc, char *argv[]) return 1; } - QApplication a(argc, argv); + // To start QApplication without X-server (non-GUI system) should use: + // "export QT_QPA_PLATFORM=offscreen" in plain shell + // or + // "Environment=QT_QPA_PLATFORM=offscreen" in systemd service ([Service] section) + + QApplication a(argc, argv, false); QString configFile; for (int i = 1; i < argc; i++) { diff --git a/systemd/ircabot.service b/systemd/ircabot.service index eca46c9..a366ccd 100644 --- a/systemd/ircabot.service +++ b/systemd/ircabot.service @@ -8,7 +8,9 @@ Type=idle User=USERNAME # Change paths to actual (like a /srv/ircabot or something): ExecStart=/path/to/ircabot -c /path/to/ircabot.conf +# To run on non-GUI system: +Environment=QT_QPA_PLATFORM=offscreen Restart=on-failure [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target