From 9173eec402f9da453dee4f56c883ac5df665d3f6 Mon Sep 17 00:00:00 2001 From: lizzie Date: Thu, 2 Oct 2025 23:39:59 +0200 Subject: [PATCH] [compat] fix logind DBus on non-linux unixes (#2648) Backported from FreeBSD ports patches Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2648 Reviewed-by: crueter Reviewed-by: MaranBr Co-authored-by: lizzie Co-committed-by: lizzie --- src/yuzu/main.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index fc7a953d77..4d5238643c 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1770,16 +1770,25 @@ void GMainWindow::OnDisplayTitleBars(bool show) { void GMainWindow::SetupPrepareForSleep() { #ifdef __unix__ - auto bus = QDBusConnection::systemBus(); - if (bus.isConnected()) { + if (auto bus = QDBusConnection::systemBus(); bus.isConnected()) { + // See https://github.com/ConsoleKit2/ConsoleKit2/issues/150 +#ifdef __linux__ + const auto dbus_logind_service = QStringLiteral("org.freedesktop.login1"); + const auto dbus_logind_path = QStringLiteral("/org/freedesktop/login1"); + const auto dbus_logind_manager_if = QStringLiteral("org.freedesktop.login1.Manager"); + //const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.login1.Session"); +#else + const auto dbus_logind_service = QStringLiteral("org.freedesktop.ConsoleKit"); + const auto dbus_logind_path = QStringLiteral("/org/freedesktop/ConsoleKit/Manager"); + const auto dbus_logind_manager_if = QStringLiteral("org.freedesktop.ConsoleKit.Manager"); + //const auto dbus_logind_session_if = QStringLiteral("org.freedesktop.ConsoleKit.Session"); +#endif const bool success = bus.connect( - QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), - QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), + dbus_logind_service, dbus_logind_path, + dbus_logind_manager_if, QStringLiteral("PrepareForSleep"), QStringLiteral("b"), this, SLOT(OnPrepareForSleep(bool))); - - if (!success) { + if (!success) LOG_WARNING(Frontend, "Couldn't register PrepareForSleep signal"); - } } else { LOG_WARNING(Frontend, "QDBusConnection system bus is not connected"); }