MauiMan

mauimanutils.cpp
1#include "mauimanutils.h"
2
3#if !defined Q_OS_ANDROID
4#include <QtDBus/QDBusConnection>
5#include <QtDBus/QDBusConnectionInterface>
6#include <QtDBus/QDBusServiceWatcher>
7#endif
8
9#include <QDebug>
10#include <QStringList>
11
12#include <QProcess>
13
14static const QString mauimanInterface(QStringLiteral("org.mauiman.Manager"));
15
16MauiManUtils::MauiManUtils(QObject *parent)
17: QObject{parent}
18{
19 #if !defined Q_OS_ANDROID
21 const auto registeredServices = bus.interface()->registeredServiceNames();
22
23 if (registeredServices.isValid())
24 {
25 m_serverRunning = registeredServices.value().contains(mauimanInterface);
26 }
27
29
30 connect(watcher, &QDBusServiceWatcher::serviceRegistered, [=](const QString &name) {
31 qDebug() << "Connected to MauiMan server" << name;
32 m_serverRunning = true;
33 Q_EMIT serverRunningChanged(m_serverRunning);
34 });
35
36 connect(watcher, &QDBusServiceWatcher::serviceUnregistered, [=](const QString &name) {
37 qDebug() << "Disconnected to MauiMan server" << name;
38 m_serverRunning = false;
39 Q_EMIT serverRunningChanged(m_serverRunning);
40 });
41 #endif
42}
43
45{
46 return m_serverRunning;
47}
48
50{
51 #if !defined Q_OS_ANDROID
52 QProcess::startDetached(QStringLiteral("MauiManServer"), QStringList());
53 #endif
54}
55
57{
58 QProcess::startDetached(QStringLiteral("MauiSettings"), QStringList {QStringLiteral("-m"), module});
59}
60
62{
63 if(qEnvironmentVariableIsSet("XDG_CURRENT_DESKTOP"))
64 {
65 const auto names = qEnvironmentVariable("XDG_CURRENT_DESKTOP").split(QStringLiteral(";"));
66 return names.first();
67 }
68
69 return QString();
70}
71
73{
74 return currentDesktopSession() == QStringLiteral("CASK");
75}
76
78{
79 return currentDesktopSession() == QStringLiteral("KDE");
80}
81
83{
84 return currentDesktopSession() == QStringLiteral("Gnome");
85}
bool serverRunning
Whether the server application is running, listening and broadcasting events.
static void startServer()
Invoke the MauiManServer4 application to be launched.
static bool isPlasmaSession()
Whether the current desktop environment session is Plasma from KDE.
static QString currentDesktopSession()
The name of the current desktop environment.
static bool isGnomeSession()
Whether the current desktop environment is GNOME Shell.
static void invokeManager(const QString &module)
Invoke the MauiSettings application to be launched at a given module name.
static bool isMauiSession()
Whether the current desktop environment session is running Maui Shell.
QString name(StandardAction id)
QDBusConnectionInterface * interface() const const
QDBusConnection sessionBus()
void serviceRegistered(const QString &serviceName)
void serviceUnregistered(const QString &serviceName)
bool startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.