File indexing completed on 2024-05-19 05:29:57
0001 /* 0002 This file is part of the KDE project 0003 0004 SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com> 0005 SPDX-FileCopyrightText: 2007 Michael Jansen <kde@michael-jansen.biz> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #include "kglobalaccel_version.h" 0011 #include "kglobalacceld.h" 0012 #include "logging_p.h" 0013 0014 #include <KAboutData> 0015 #include <KCrash> 0016 #include <KDBusService> 0017 #include <QCommandLineParser> 0018 #include <QGuiApplication> 0019 0020 int main(int argc, char **argv) 0021 { 0022 // On Wayland the shortcuts are ran as part of kwin_wayland 0023 // no-op when started on Wayland 0024 if (qEnvironmentVariable("XDG_SESSION_TYPE") == QLatin1String("wayland")) { 0025 return 0; 0026 } 0027 0028 auto sessionManager = qgetenv("SESSION_MANAGER"); 0029 // Disable Session Management the right way (C) 0030 // 0031 // ksmserver has global shortcuts. disableSessionManagement() does not prevent Qt from 0032 // registering the app with the session manager. We remove the address to make sure we do not 0033 // get a hang on kglobalaccel restart (kglobalaccel tries to register with ksmserver, 0034 // ksmserver tries to register with kglobalaccel). 0035 qunsetenv("SESSION_MANAGER"); 0036 0037 QGuiApplication::setDesktopSettingsAware(false); 0038 QGuiApplication::setQuitLockEnabled(false); 0039 QGuiApplication app(argc, argv); 0040 KAboutData aboutdata(QStringLiteral("kglobalaccel"), 0041 QObject::tr("KDE Global Shortcuts Service"), 0042 QStringLiteral(KGLOBALACCEL_VERSION_STRING), 0043 QObject::tr("KDE Global Shortcuts Service"), 0044 KAboutLicense::LGPL, 0045 QStringLiteral("(C) 2007-2009 Andreas Hartmetz, Michael Jansen")); 0046 aboutdata.addAuthor(QStringLiteral("Andreas Hartmetz"), QObject::tr("Maintainer"), QStringLiteral("ahartmetz@gmail.com")); 0047 aboutdata.addAuthor(QStringLiteral("Michael Jansen"), QObject::tr("Maintainer"), QStringLiteral("kde@michael-jansen.biz")); 0048 0049 KAboutData::setApplicationData(aboutdata); 0050 0051 { 0052 QCommandLineParser parser; 0053 aboutdata.setupCommandLine(&parser); 0054 parser.process(app); 0055 aboutdata.processCommandLine(&parser); 0056 } 0057 0058 KDBusService service(KDBusService::Unique); 0059 0060 app.setQuitOnLastWindowClosed(false); 0061 0062 if (!sessionManager.isEmpty()) { 0063 qputenv("SESSION_MANAGER", sessionManager); 0064 } 0065 0066 // Restart on a crash 0067 KCrash::setFlags(KCrash::AutoRestart); 0068 0069 KGlobalAccelD globalaccel; 0070 if (!globalaccel.init()) { 0071 return -1; 0072 } 0073 0074 return app.exec(); 0075 }