Skip to content

Take into account logind sleep and idle inhibitions

Kai Uwe Broulik requested to merge work/kbroulik/logind-inhibitions into master

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 the BlockInhibitors is emitted every time a blocking inhibition is added/removed, even if the actual modes that are blocked didn't change…

Screenshot_20201202_201727

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

Merge request reports