1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2  * (c)LGPL2+
3  *
4  * LXQt - a lightweight, Qt based, desktop toolset
5  *
6  * Authors:
7  *   Christian Surlykke <christian@surlykke.dk>
8  *
9  * This program or library is free software; you can redistribute it
10  * and/or modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18 
19  * You should have received a copy of the GNU Lesser General
20  * Public License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  * Boston, MA 02110-1301 USA
23  *
24  * END_COMMON_COPYRIGHT_HEADER */
25 
26 #include <QDBusConnection>
27 #include <QDebug>
28 #include <QCommandLineParser>
29 
30 #include <LXQt/Application>
31 
32 #include "powermanagementd.h"
33 
main(int argc,char * argv[])34 int main(int argc, char *argv[])
35 {
36 
37     LXQt::Application a(argc, argv);
38     a.setQuitOnLastWindowClosed(false);
39 
40     QCommandLineParser parser;
41     parser.setApplicationDescription(QStringLiteral("LXQt Powermanagement Daemon"));
42     const QString VERINFO = QSL(LXQT_POWERMANAGEMENT_VERSION \
43                             "\nliblxqt   " LXQT_VERSION \
44                             "\nQt        " QT_VERSION_STR);
45     a.setApplicationVersion(VERINFO);
46     parser.addVersionOption();
47     parser.addHelpOption();
48     parser.process(a);
49 
50     // To ensure only one instance of lxqt-powermanagement is running we register as a DBus service and refuse to run
51     // if not able to do so.
52     // We do not register any object as we don't have any dbus-operations to expose.
53     if (! QDBusConnection::sessionBus().registerService(QSL("org.lxqt.lxqt-powermanagement")))
54     {
55         qWarning() << "Unable to register 'org.lxqt.lxqt-powermanagement' service - is another instance of lxqt-powermanagement running?";
56         return 1;
57     }
58     else
59     {
60         PowerManagementd powerManagementd;
61         return a.exec();
62     }
63 }
64