From 9dc13079970d28c499c5ca77aa7d9c3f0da4eaa0 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Thu, 20 May 2021 15:51:55 +0200 Subject: [PATCH] PowerDevilRunner: Set screen brightness values powerdevil expects the brightness to be in absolute values not percentages. I know this is a blocking call, but we use QDBusInterfaces and other blocking calls in here so it's not great but is a reasonable fix for now. BUG: 437408 --- runners/powerdevil/PowerDevilRunner.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runners/powerdevil/PowerDevilRunner.cpp b/runners/powerdevil/PowerDevilRunner.cpp index 48a9d62c9..676a065a8 100644 --- a/runners/powerdevil/PowerDevilRunner.cpp +++ b/runners/powerdevil/PowerDevilRunner.cpp @@ -32,6 +32,8 @@ #include #include +#include + K_EXPORT_PLASMA_RUNNER_WITH_JSON(PowerDevilRunner, "plasma-runner-powerdevil.json") PowerDevilRunner::PowerDevilRunner(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args) @@ -179,7 +181,9 @@ void PowerDevilRunner::run(const Plasma::RunnerContext &context, const Plasma::Q if (match.id().startsWith(QLatin1String("PowerDevil_ProfileChange"))) { iface.asyncCall(QStringLiteral("loadProfile"), match.data().toString()); } else if (match.id() == QLatin1String("PowerDevil_BrightnessChange")) { - brightnessIface.asyncCall(QStringLiteral("setBrightness"), match.data().toInt()); + QDBusReply max = brightnessIface.call("brightnessMax"); + const int value = max.isValid() ? std::round(match.data().toInt() * max / 100.0) : match.data().toInt(); + brightnessIface.asyncCall("setBrightness", value); } else if (match.id() == QLatin1String("PowerDevil_DimTotal")) { brightnessIface.asyncCall(QStringLiteral("setBrightness"), 0); } else if (match.id() == QLatin1String("PowerDevil_DimHalf")) {