From 5ce731d54f144f5bbbd391741adb0c236bcbb26b Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Sun, 30 Aug 2026 23:15:18 -0400 Subject: [PATCH] fix(core): use standard screen saver lock API --- powerman/dimdisplayaction.cpp | 9 +++++++-- shutdown-ui/actions.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/powerman/dimdisplayaction.cpp b/powerman/dimdisplayaction.cpp index 2fdcb71..2c8f36b 100644 --- a/powerman/dimdisplayaction.cpp +++ b/powerman/dimdisplayaction.cpp @@ -19,10 +19,11 @@ ***************************************************************************/ #include "dimdisplayaction.h" +#include "screenlocker_interface.h" + #include #include #include -#include #include DimDisplayAction::DimDisplayAction(QObject *parent) @@ -73,7 +74,11 @@ void DimDisplayAction::onIdleTimeout(int msec) } if (m_lock) { - QProcess::startDetached("cutefish-screenlocker", QStringList()); + OrgFreedesktopScreenSaverInterface screenSaver( + QStringLiteral("org.freedesktop.ScreenSaver"), + QStringLiteral("/ScreenSaver"), + QDBusConnection::sessionBus()); + screenSaver.Lock(); } } else if (sec == (m_dimOnIdleTime * 3 / 4)) { diff --git a/shutdown-ui/actions.cpp b/shutdown-ui/actions.cpp index 76bea07..3010a13 100644 --- a/shutdown-ui/actions.cpp +++ b/shutdown-ui/actions.cpp @@ -21,12 +21,15 @@ #include #include #include -#include const static QString s_dbusName = "com.cutefish.Session"; const static QString s_pathName = "/Session"; const static QString s_interfaceName = "com.cutefish.Session"; +const static QString s_screenSaverService = "org.freedesktop.ScreenSaver"; +const static QString s_screenSaverPath = "/ScreenSaver"; +const static QString s_screenSaverInterface = "org.freedesktop.ScreenSaver"; + Actions::Actions(QObject *parent) : QObject(parent) { @@ -59,7 +62,13 @@ void Actions::reboot() void Actions::lockScreen() { - QProcess::startDetached("cutefish-screenlocker", QStringList()); + QDBusInterface iface(s_screenSaverService, + s_screenSaverPath, + s_screenSaverInterface, + QDBusConnection::sessionBus()); + if (iface.isValid()) { + iface.call(QStringLiteral("Lock")); + } qApp->exit(0); }