From 57e3989185b8209a11d79bac477479019d515180 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 24 Sep 2025 23:48:47 +1000 Subject: plugin: add hypr extras (#690) * move machine * works * prevent duplicate refreshes * use instead of hyprctl proc --- plugin/src/Caelestia/Internal/hyprextras.hpp | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 plugin/src/Caelestia/Internal/hyprextras.hpp (limited to 'plugin/src/Caelestia/Internal/hyprextras.hpp') diff --git a/plugin/src/Caelestia/Internal/hyprextras.hpp b/plugin/src/Caelestia/Internal/hyprextras.hpp new file mode 100644 index 0000000..ca1b2f2 --- /dev/null +++ b/plugin/src/Caelestia/Internal/hyprextras.hpp @@ -0,0 +1,51 @@ +#pragma once + +#include "hyprdevices.hpp" +#include +#include +#include + +namespace caelestia::internal::hypr { + +class HyprExtras : public QObject { + Q_OBJECT + QML_ELEMENT + + Q_PROPERTY(QVariantHash options READ options NOTIFY optionsChanged) + Q_PROPERTY(HyprDevices* devices READ devices CONSTANT) + +public: + explicit HyprExtras(QObject* parent = nullptr); + + [[nodiscard]] QVariantHash options() const; + [[nodiscard]] HyprDevices* devices() const; + + Q_INVOKABLE void message(const QString& message); + + Q_INVOKABLE void refreshOptions(); + Q_INVOKABLE void refreshDevices(); + +signals: + void optionsChanged(); + +private: + using SocketPtr = QSharedPointer; + + QString m_requestSocket; + QString m_eventSocket; + QLocalSocket* m_socket; + + QVariantHash m_options; + HyprDevices* const m_devices; + + SocketPtr m_optionsRefresh; + SocketPtr m_devicesRefresh; + + void readEvent(); + void handleEvent(const QString& event); + + SocketPtr makeRequestJson(const QString& request, const std::function& callback); + SocketPtr makeRequest(const QString& request, const std::function& callback); +}; + +} // namespace caelestia::internal::hypr -- cgit v1.2.3-freya