-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
55 lines (44 loc) · 1.66 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QString>
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
#include <QtCore/QCommandLineParser>
#include "utils/plasma.h"
#include "exceptions/RuntimeException.h"
int main(int argc, char **argv) {
Q_UNUSED(argc)
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("Plasma theme switcher");
QCoreApplication::setApplicationVersion("0.1");
QCommandLineParser parser;
parser.setApplicationDescription("Quickly apply plasma color schemes and widget styles from the command-line");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption colorShemeOption(
QStringList{"c", "colors"},
"A file containing plasma color scheme information. Use this argument once to apply directly or twice to cycle.",
"colors"
);
QCommandLineOption widgetStyleOption(
QStringList{"w", "widgetStyle"},
R"(Name of widget style to apply. Use argument once to apply directly or twice to cycle.")",
"widgetStyle"
);
parser.addOption(colorShemeOption);
parser.addOption(widgetStyleOption);
parser.process(app);
if (!(parser.isSet(colorShemeOption) || parser.isSet(widgetStyleOption))) {
parser.showHelp(1);
}
try {
if (parser.isSet(colorShemeOption)) {
plasmaApplyColorScheme(parser.values(colorShemeOption));
}
if (parser.isSet(widgetStyleOption)) {
plasmaApplyWidgetStyle(parser.values(widgetStyleOption));
}
} catch (RuntimeException &e) {
QTextStream(stderr) << "ERR: " << e.message() << "\n";
return 1;
}
return 0;
}