GCC Code Coverage Report


Directory: ./
File: ctl/main.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 0 29 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 SPDX-FileCopyrightText: 2014, 2015 by Sebastian K├╝gler <sebas@kde.org>
3 SPDX-FileCopyrightText: 2020 Roman Gilg <subdiff@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only
6 */
7 #include "doctor.h"
8
9 #include <QCommandLineParser>
10 #include <QGuiApplication>
11
12 /** Usage example:
13 * dismanctl --set output.0.disable output.1.mode.1 output.1.enable"
14 *
15 * Error codes:
16 * 2 : general parse error
17 * 3 : output id parse error
18 * 4 : mode id parse error
19 * 5 : position parse error
20 *
21 * 8 : invalid output id
22 * 9 : invalid mode id
23 *
24 */
25
26 int main(int argc, char** argv)
27 {
28 const QString desc = QStringLiteral(
29 "dismanctl allows to change the screen setup from the command-line.\n"
30 "\n"
31 "Setting the output configuration is done in an atomic fashion, all settings\n"
32 "are applied in a single command.\n"
33 "dismanctl can be used to enable and disable outputs, to position screens,\n"
34 "change resolution (mode setting), etc.. You should put all your options into \n"
35 "a single invocation of dismanctl, so they can all be applied at once.\n"
36 "\n"
37 "Usage examples:\n\n"
38 " Show output information:\n"
39 " $ dismanctl -o\n"
40 " Output: 1 eDP-1 enabled connected Panel Modes: Modes: 1:800x600@60 [...] Geometry: 0,0 "
41 "1280x800\n"
42 " Output: 70 HDMI-2 enabled connected HDMI Modes: 1:800x600@60 [...] Geometry: 1280,0 "
43 "1920x1080\n"
44 "\n Disable the hdmi output, enable the laptop panel and set it to a specific mode\n"
45 " $ dismanctl output.HDMI-2.disable output.eDP-1.mode.1 output.eDP-1.enable\n"
46 "\n Position the hdmi monitor on the right of the laptop panel\n"
47 " $ dismanctl output.HDMI-2.position.0,1280 output.eDP-1.position.0,0\n"
48 "\n Set resolution mode\n"
49 " $ dismanctl output.HDMI-2.mode.1920x1080@60 \n"
50 "\n Set scale (note: fractional scaling is only supported on wayland)\n"
51 " $ dismanctl output.HDMI-2.scale.2 \n"
52 "\n Set rotation (possible values: none, left, right, inverted)\n"
53 " $ dismanctl output.HDMI-2.rotation.left \n");
54 /*
55 "\nError codes:\n"
56 " 2 : general parse error\n"
57 " 3 : output id parse error\n"
58 " 4 : mode id parse error\n"
59 " 5 : position parse error\n"
60
61 " 8 : invalid output id\n"
62 " 9 : invalid mode id\n";
63 */
64 const QString syntax = QStringLiteral(
65 "Specific output settings are separated by spaces, each setting is in the form of\n"
66 "output.<name>.<setting>[.<value>]\n"
67 "For example:\n"
68 " $ dismanctl output.HDMI-2.enable \\\n"
69 " output.eDP-1.mode.4 \\\n"
70 " output.eDP-1.position.1280,0\n"
71 "Multiple settings are passed in order to have dismanctl apply these settings in one "
72 "go.\n");
73
74 QGuiApplication app(argc, argv);
75
76 QCommandLineOption info
77 = QCommandLineOption(QStringList() << QStringLiteral("i") << QStringLiteral("info"),
78 QStringLiteral("Show runtime information: backends, logging, etc."));
79 QCommandLineOption outputs
80 = QCommandLineOption(QStringList() << QStringLiteral("o") << QStringLiteral("outputs"),
81 QStringLiteral("Show outputs"));
82 QCommandLineOption json
83 = QCommandLineOption(QStringList() << QStringLiteral("j") << QStringLiteral("json"),
84 QStringLiteral("Show configuration in JSON format"));
85 QCommandLineOption log
86 = QCommandLineOption(QStringList() << QStringLiteral("l") << QStringLiteral("log"),
87 QStringLiteral("Write a comment to the log file"),
88 QStringLiteral("comment"));
89 QCommandLineOption watch
90 = QCommandLineOption(QStringList() << QStringLiteral("w") << QStringLiteral("watch"),
91 QStringLiteral("Watch for changes and print them to stdout."));
92
93 QCommandLineParser parser;
94 parser.setApplicationDescription(desc);
95 parser.addPositionalArgument(
96 QStringLiteral("config"),
97 syntax,
98 QStringLiteral("[output.<name>.<setting> output.<name>.setting [...]]"));
99 parser.addHelpOption();
100 parser.addOption(info);
101 parser.addOption(json);
102 parser.addOption(outputs);
103 parser.addOption(log);
104 parser.addOption(watch);
105 parser.process(app);
106
107 Disman::Ctl::Doctor server(&parser);
108
109 return app.exec();
110 }
111