[PATCH] (issue50) Write startup file with display variable

Wald Commits scm-commit at wald.intevation.org
Tue Jul 29 13:15:38 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1406632532 -7200
# Node ID c9a31544aaab78d7374a3e6179757322480d2e33
# Parent  b108510bac5af2bba8d89ac3ac5249653de99fc7
(issue50) Write startup file with display variable

diff -r b108510bac5a -r c9a31544aaab ui/main.cpp
--- a/ui/main.cpp	Mon Jul 28 18:42:59 2014 +0200
+++ b/ui/main.cpp	Tue Jul 29 13:15:32 2014 +0200
@@ -14,6 +14,7 @@
 #endif
 
 #include <QApplication>
+#include <QFile>
 #include <QSystemTrayIcon>
 #include <QtPlugin>
 #include <QMessageBox>
@@ -31,6 +32,10 @@
 #define APPNAME "TrustBridge"
 #endif
 
+#ifndef STARTUP_FILE_NAME
+#define STARTUP_FILE_NAME "trustbridge-tray-starter.cfg"
+#endif
+
 #ifndef ORGANIZATION
 #define ORGANIZATION "BSI"
 #endif
@@ -118,8 +123,13 @@
         qDebug() << " task sched done: " << taskSched.createDailyTask(QCoreApplication::applicationFilePath(),
                 QString::fromLatin1("--tray"), QTime::currentTime());
     }
+#else
+    /* Save the display on start so that it might later be used by the cron startup script. */
+    QFile startup_file (settings.fileName().replace(APPNAME ".ini", STARTUP_FILE_NAME));
+    startup_file.open(QIODevice::WriteOnly);
+    startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8());
+    startup_file.close();
 #endif
-
     MainWindow mainWin(trayMode);
 
     return app.exec();


More information about the Trustbridge-commits mailing list