summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp')
-rw-r--r--accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp
index 615024d2..98f73d8f 100644
--- a/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp
+++ b/accounts/gkleen@sif/shell/quickshell-plugins/Systemd.hpp
@@ -3,6 +3,7 @@
3#include <cstdint> 3#include <cstdint>
4#include <memory> 4#include <memory>
5#include <string> 5#include <string>
6#include <optional>
6 7
7#include <QObject> 8#include <QObject>
8#include <QDBusInterface> 9#include <QDBusInterface>
@@ -11,8 +12,47 @@
11#include "dbus_systemd_manager.h" 12#include "dbus_systemd_manager.h"
12#include "dbus_logind_manager.h" 13#include "dbus_logind_manager.h"
13#include "dbus_logind_session.h" 14#include "dbus_logind_session.h"
15#include "dbus_systemd_unit.h"
16#include "dbus_systemd_service.h"
14#include "dbus_properties.h" 17#include "dbus_properties.h"
15 18
19#include "core/model.hpp"
20
21class SystemdUnit : public QObject {
22 Q_OBJECT;
23 QML_ELEMENT;
24 QML_UNCREATABLE("SystemdUnits cannot be created directly");
25
26public:
27 explicit SystemdUnit(QObject* parent, const QDBusObjectPath& path, const QString& id);
28
29 Q_PROPERTY(QDBusObjectPath path READ path CONSTANT);
30 Q_PROPERTY(QString id READ id CONSTANT);
31 Q_PROPERTY(QList<QString> runtimeDirectory READ runtimeDirectory CONSTANT);
32 Q_PROPERTY(QString activeState READ activeState NOTIFY activeStateChanged);
33
34 const QDBusObjectPath& path() const;
35 const QString& id() const;
36 QList<QString> runtimeDirectory();
37 QString activeState();
38
39signals:
40 void activeStateChanged();
41
42private slots:
43 void onUnitPropertiesChanged(const QString& interface_name, const QVariantMap& changed_properties, const QStringList& invalidated_properties);
44
45private:
46 std::unique_ptr<DBusSystemdUnit> systemdUnit();
47 std::unique_ptr<DBusSystemdService> systemdService();
48
49 DBusProperties* mUnitProperties;
50 QDBusObjectPath mPath;
51 QString mId;
52 std::optional<QString> mActiveState;
53 std::optional<QList<QString>> mRuntimeDirectory;
54};
55
16class Systemd : public QObject { 56class Systemd : public QObject {
17 Q_OBJECT; 57 Q_OBJECT;
18 QML_SINGLETON; 58 QML_SINGLETON;
@@ -23,6 +63,7 @@ public:
23 63
24 Q_PROPERTY(bool idleHint READ idleHint WRITE setIdleHint NOTIFY idleHintChanged) 64 Q_PROPERTY(bool idleHint READ idleHint WRITE setIdleHint NOTIFY idleHintChanged)
25 Q_PROPERTY(bool lockedHint READ lockedHint WRITE setLockedHint NOTIFY lockedHintChanged) 65 Q_PROPERTY(bool lockedHint READ lockedHint WRITE setLockedHint NOTIFY lockedHintChanged)
66 Q_PROPERTY(UntypedObjectModel* userUnits READ userUnits CONSTANT)
26 67
27 Q_INVOKABLE void stopUserUnit(const QString& unit, const QString& mode); 68 Q_INVOKABLE void stopUserUnit(const QString& unit, const QString& mode);
28 Q_INVOKABLE void setBrightness(const QString& subsystem, const QString& name, quint32 brightness); 69 Q_INVOKABLE void setBrightness(const QString& subsystem, const QString& name, quint32 brightness);
@@ -34,6 +75,7 @@ public:
34 75
35 bool idleHint(); 76 bool idleHint();
36 bool lockedHint(); 77 bool lockedHint();
78 ObjectModel<SystemdUnit>* userUnits();
37 79
38signals: 80signals:
39 void shutdown(bool before); 81 void shutdown(bool before);
@@ -45,12 +87,16 @@ signals:
45 87
46private slots: 88private slots:
47 void onLogindSessionPropertiesChanged(const QString& interface_name, const QVariantMap& changed_properties, const QStringList& invalidated_properties); 89 void onLogindSessionPropertiesChanged(const QString& interface_name, const QVariantMap& changed_properties, const QStringList& invalidated_properties);
90 void onUserUnitNew(const QString& id, const QDBusObjectPath& objectPath);
91 void onUserUnitRemoved(const QString& id, const QDBusObjectPath& objectPath);
48 92
49private: 93private:
50 DBusSystemdManager* systemdManager; 94 DBusSystemdManager* systemdManager;
51 DBusLogindManager* logindManager; 95 DBusLogindManager* logindManager;
52 DBusLogindSession* logindSession; 96 DBusLogindSession* logindSession;
53 DBusProperties* logindSessionProperties; 97 DBusProperties* logindSessionProperties;
98
99 ObjectModel<SystemdUnit> mUserUnits{this};
54}; 100};
55 101
56class SystemdInhibitorParams : public QObject { 102class SystemdInhibitorParams : public QObject {