From ed28d8b56a9705e9a5194b3ad64b744a09e90d44 Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Wed, 3 Jun 2026 17:41:17 +0200 Subject: [PATCH] Took caelestia lid logic (prepare to sleep) instead --- Plugins/ZShell/lidwatcher.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Plugins/ZShell/lidwatcher.cpp b/Plugins/ZShell/lidwatcher.cpp index 212209c..7a6105f 100644 --- a/Plugins/ZShell/lidwatcher.cpp +++ b/Plugins/ZShell/lidwatcher.cpp @@ -1,6 +1,7 @@ #include "lidwatcher.hpp" #include +#include #include #include #include @@ -56,8 +57,34 @@ LidWatcher::LidState LidWatcher::state() const { void LidWatcher::tryConnect() { QDBusConnection bus = QDBusConnection::systemBus(); + const auto iface = bus.interface(); + if (!iface) { + queryLidState(); + if (!m_available) { + m_available = true; + emit availableChanged(); + } + if (!m_pollTimer->isActive()) { + m_pollTimer->start(); +} + return; + } + const auto reply = iface->isServiceRegistered(kLogin1Service); + if (!reply.isValid() || !reply.value()) { + queryLidState(); + qCInfo(lcLidWatcher) << "login1 not available, polling"; + if (!m_available) { + m_available = true; + emit availableChanged(); + } + if (!m_pollTimer->isActive()) { + m_pollTimer->start(); +} + return; + } + const auto connected = bus.connect( - QString(), + kLogin1Service, kLogin1Path, kDBusPropertiesInterface, "PropertiesChanged",