Detect session lock on Xfce/XUbuntu 16.04

The current code does not work with XUbuntu 16.04, which uses
light-locker to lock the screen.

I am not using a screensaver, but I suspect the screensaver activation
may have been detected by the existing events, and using it could thus
mask the issue.
This commit is contained in:
Francois Ferrand 2017-08-30 17:54:15 +02:00
parent 0c3f352c63
commit 263bee3c09

View File

@ -20,6 +20,7 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDBusReply> #include <QDBusReply>
#include <QProcessEnvironment>
ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent): ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
ScreenLockListenerPrivate(parent) ScreenLockListenerPrivate(parent)
@ -51,6 +52,15 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget *parent):
this, //receiver this, //receiver
SLOT(logindPrepareForSleep(bool))); SLOT(logindPrepareForSleep(bool)));
QString sessionId = QProcessEnvironment::systemEnvironment().value("XDG_SESSION_ID");
systemBus.connect(
"", // service
QString("/org/freedesktop/login1/session/") + sessionId, // path
"org.freedesktop.login1.Session", // interface
"Lock", // signal name
this, //receiver
SLOT(unityLocked()));
sessionBus.connect( sessionBus.connect(
"com.canonical.Unity", // service "com.canonical.Unity", // service
"/com/canonical/Unity/Session", // path "/com/canonical/Unity/Session", // path