summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/Internal/hyprextras.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/src/Caelestia/Internal/hyprextras.cpp')
-rw-r--r--plugin/src/Caelestia/Internal/hyprextras.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/plugin/src/Caelestia/Internal/hyprextras.cpp b/plugin/src/Caelestia/Internal/hyprextras.cpp
index 5925918..5308524 100644
--- a/plugin/src/Caelestia/Internal/hyprextras.cpp
+++ b/plugin/src/Caelestia/Internal/hyprextras.cpp
@@ -12,6 +12,7 @@ HyprExtras::HyprExtras(QObject* parent)
, m_requestSocket("")
, m_eventSocket("")
, m_socket(nullptr)
+ , m_socketValid(false)
, m_devices(new HyprDevices(this)) {
const auto his = qEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE");
if (his.isEmpty()) {
@@ -38,7 +39,11 @@ HyprExtras::HyprExtras(QObject* parent)
refreshDevices();
m_socket = new QLocalSocket(this);
+
+ QObject::connect(m_socket, &QLocalSocket::errorOccurred, this, &HyprExtras::socketError);
+ QObject::connect(m_socket, &QLocalSocket::stateChanged, this, &HyprExtras::socketStateChanged);
QObject::connect(m_socket, &QLocalSocket::readyRead, this, &HyprExtras::readEvent);
+
m_socket->connectToServer(m_eventSocket, QLocalSocket::ReadOnly);
}
@@ -55,7 +60,10 @@ void HyprExtras::message(const QString& message) {
return;
}
- makeRequest(message, [](bool, const QByteArray&) {
+ makeRequest(message, [](bool success, const QByteArray& res) {
+ if (!success) {
+ qWarning() << "HyprExtras::message: request error:" << QString::fromUtf8(res);
+ }
});
}
@@ -64,7 +72,10 @@ void HyprExtras::batchMessage(const QStringList& messages) {
return;
}
- makeRequest("[[BATCH]]" + messages.join(";"), [](bool, const QByteArray&) {
+ makeRequest("[[BATCH]]" + messages.join(";"), [](bool success, const QByteArray& res) {
+ if (!success) {
+ qWarning() << "HyprExtras::batchMessage: request error:" << QString::fromUtf8(res);
+ }
});
}
@@ -78,9 +89,11 @@ void HyprExtras::applyOptions(const QVariantHash& options) {
request += QString("keyword %1 %2;").arg(it.key(), it.value().toString());
}
- makeRequest(request, [this](bool success, const QByteArray&) {
+ makeRequest(request, [this](bool success, const QByteArray& res) {
if (success) {
refreshOptions();
+ } else {
+ qWarning() << "HyprExtras::applyOptions: request error" << QString::fromUtf8(res);
}
});
}
@@ -128,6 +141,22 @@ void HyprExtras::refreshDevices() {
});
}
+void HyprExtras::socketError(QLocalSocket::LocalSocketError error) const {
+ if (!m_socketValid) {
+ qWarning() << "HyprExtras::socketError: unable to connect to Hyprland event socket:" << error;
+ } else {
+ qWarning() << "HyprExtras::socketError: Hyprland event socket error:" << error;
+ }
+}
+
+void HyprExtras::socketStateChanged(QLocalSocket::LocalSocketState state) {
+ if (state == QLocalSocket::UnconnectedState && m_socketValid) {
+ qWarning() << "HyprExtras::socketStateChanged: Hyprland event socket disconnected.";
+ }
+
+ m_socketValid = state == QLocalSocket::ConnectedState;
+}
+
void HyprExtras::readEvent() {
while (true) {
auto rawEvent = m_socket->readLine();