Skip to content

Commit 6ee0288

Browse files
author
ThePBone
committed
Fix automatic-startup issues
1 parent d6733da commit 6ee0288

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

main.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <QScreen>
99
#include <string>
1010
#include <iostream>
11+
#include <unistd.h>
1112

1213
#define FORCE_CRASH_HANDLER
1314

@@ -39,23 +40,39 @@ int main(int argc, char *argv[])
3940
airbag_init_fd(fd,crash_handled,EXECUTION_FILENAME);
4041
#endif
4142

42-
4343
QApplication a(argc, argv);
4444
QCommandLineParser parser;
4545
parser.setApplicationDescription("Graphical User Interface for Viper4Linux2");
4646
parser.addHelpOption();
4747

48-
QCommandLineOption tray(QStringList() << "t" << "tray", "Start minimized in systray (forced)");
48+
QCommandLineOption tray(QStringList() << "t" << "tray", "Start minimized in systray delayed (forced)");
4949
parser.addOption(tray);
50+
QCommandLineOption nowtray(QStringList() << "i" << "instant-tray", "Start minimized in systray instantly (forced)");
51+
parser.addOption(nowtray);
5052
QCommandLineOption sviper(QStringList() << "s" << "startviper", "Start viper on launch");
5153
parser.addOption(sviper);
5254
QCommandLineOption minst(QStringList() << "m" << "allow-multiple-instances", "Allow multiple instances of this app");
5355
parser.addOption(minst);
5456
parser.process(a);
55-
if(parser.isSet(sviper)) system("viper start");
57+
58+
if(parser.isSet(sviper)){
59+
system("viper start");
60+
usleep(300);
61+
}
62+
63+
if(parser.isSet(tray)){
64+
//Delay startup to make sure that the DE is ready
65+
usleep(1000);
66+
}
67+
68+
bool startInTray = parser.isSet(tray) || parser.isSet(nowtray);
5669

5770
QApplication::setQuitOnLastWindowClosed( false );
58-
MainWindow w(QString::fromLocal8Bit(exepath),parser.isSet(tray),parser.isSet(minst));
71+
MainWindow w(QString::fromLocal8Bit(exepath),
72+
startInTray,
73+
parser.isSet(minst));
74+
75+
w.setVisible(!startInTray);
5976
w.setFixedSize(w.geometry().width(),w.geometry().height());
6077
w.setGeometry(
6178
QStyle::alignedRect(

0 commit comments

Comments
 (0)