Take into account logind sleep and idle inhibitions
System services cannot access the user's session bus and that freedesktop inhibition interface appears deprecated. This patch makes PowerDevil watch logind's BlockInhibited property and internally posts an appropriate inhibition.
BUG: 364067 FIXED-IN: 5.21.0
@davidedmundson @bshah @bruns @fvogt
- Verified with the following test application as I don't know what services use sleep/idle inhibitions. I just know that Apt posts a shutdown inhibition during package installation (which I don't think we handle anywhere either)
- They also survive PowerDevil restart because they're handled by logind
- No idea about consolekit
- There's no dedicated signal for
Inhibitors
but theBlockInhibitors
is emitted every time a blocking inhibition is added/removed, even if the actual modes that are blocked didn't change…
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.login1"),
QStringLiteral("/org/freedesktop/login1"),
QStringLiteral("org.freedesktop.login1.Manager"),
QStringLiteral("Inhibit"));
msg.setArguments({"sleep", "dolphin", "Because I say so", "block"});
QDBusMessage reply = QDBusConnection::systemBus().call(msg);
const QDBusUnixFileDescriptor fd = reply.arguments().first().value<QDBusUnixFileDescriptor>();
return app.exec();
}
Edited by Kai Uwe Broulik