SHA256
1
0
forked from pool/powerdevil6

Accepting request 1181277 from KDE:Frameworks

OBS-URL: https://build.opensuse.org/request/show/1181277
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/powerdevil6?expand=0&rev=7
This commit is contained in:
Ana Guerrero 2024-06-22 11:22:41 +00:00 committed by Git OBS Bridge
commit 24f68b5b9c
7 changed files with 800 additions and 25 deletions

View File

@ -0,0 +1,748 @@
From 93066eb9ec30ec23ca0eba8eebf4148533f5bd90 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Mon, 17 Jun 2024 11:49:22 +0200
Subject: [PATCH] Revert "Added setting for battery conservation mode (Lenovo)"
This reverts commit 53f688de8eff37a52efed55b52d9e51f5217a185.
---
daemon/chargethreshold_helper_actions.actions | 120 -------------
daemon/chargethresholdhelper.cpp | 52 ------
daemon/chargethresholdhelper.h | 4 -
daemon/dbus/org.kde.Solid.PowerManagement.xml | 6 -
daemon/powerdevilcore.cpp | 30 ----
daemon/powerdevilcore.h | 4 -
kcmodule/profiles/ExternalServiceSettings.cpp | 158 +++++-------------
kcmodule/profiles/ExternalServiceSettings.h | 20 ---
kcmodule/profiles/PowerKCM.cpp | 6 -
kcmodule/profiles/PowerKCM.h | 3 -
kcmodule/profiles/ui/GlobalConfig.qml | 16 +-
11 files changed, 43 insertions(+), 376 deletions(-)
Index: powerdevil-6.1.0/daemon/chargethreshold_helper_actions.actions
===================================================================
--- powerdevil-6.1.0.orig/daemon/chargethreshold_helper_actions.actions
+++ powerdevil-6.1.0/daemon/chargethreshold_helper_actions.actions
@@ -231,111 +231,3 @@ Description[zh_CN]=请进行身份验证
Description[zh_TW]=認證以設定電池充電限制。
Policy=auth_admin
Persistence=session
-
-[org.kde.powerdevil.chargethresholdhelper.getconservationmode]
-Name=Check battery conservation mode
-Name[ar]=تحقق من وضع الحفاظ على البطارية
-Name[bg]=Проверка на режима за пестене на батерията
-Name[ca]=Comprova el mode de conservació de la bateria
-Name[ca@valencia]=Comprova el mode de conservació de la bateria
-Name[en_GB]=Check battery conservation mode
-Name[eo]=Kontroli baterikonservan reĝimon
-Name[es]=Comprobar el modo de conservación de la batería
-Name[eu]=Egiaztatu bateriaren kontserbazio-modua
-Name[fr]=Vérifier le mode d'économie d'énergie
-Name[he]=בדיקת מצב שימור סוללה
-Name[hu]=Akkumulátorkíméló mód ellenőrzése
-Name[ia]=Verifica le modo de conservation de batteria
-Name[it]=Controlla la modalità di risparmio della batteria
-Name[ka]=ელემენტის შენახვის რეჟიმის შემოწმება
-Name[lt]=Tikrinti akumuliatoriaus saugojimo veikseną
-Name[nl]=Conserveringsmodus van batterij controleren
-Name[pl]=Odczytaj tryb zarządzania baterią
-Name[sk]=Skontrolovať režim ochrany batérie
-Name[sl]=Preverite način varčevanja z baterijo
-Name[tr]=Pil Tasarrufu Kipini Denetle
-Name[uk]=Перевірка режиму консервації акумулятора
-Name[x-test]=xxCheck battery conservation modexx
-Name[zh_CN]=检查节电模式模式
-Name[zh_TW]=查看電池保護模式
-Description=Authenticate to check the current state of battery conservation mode.
-Description[ar]=استوثق للتحقق من الحالة الحالية لوضع الحفاظ على البطارية.
-Description[bg]=Удостоверете автентичността си, за да проверите текущото състояние на режима за пестене на батерията.
-Description[ca]=Autenticació per a comprovar l'estat actual del mode de conservació de la bateria.
-Description[ca@valencia]=Autenticació per a comprovar l'estat actual del mode de conservació de la bateria.
-Description[en_GB]=Authenticate to check the current state of battery conservation mode.
-Description[eo]=Aŭtentiĝu por kontroli la aktualan staton de bateriokonserva reĝimo.
-Description[es]=Debe autenticarse para comprobar el estado actual del modo de conservación de la batería.
-Description[eu]=Kautotu bateriaren kontserbazio-moduaren uneko egoera egiaztatzeko.
-Description[fr]=S'authentifier pour vérifier l'état courant à la limite actuelle de charge de la batterie
-Description[he]=יש לעבור אימות כדי לבדוק את מה המצב הנוכחי של מצב שימור הסוללה.
-Description[hu]=Hitelesítés szükséges az akkumulátorkímélő mód jelenlegi állapotának ellenőrzéséhez.
-Description[ia]=Authentica per verificar le stato currente del modo de conservation de batteria.
-Description[it]=Autenticati per controllare lo stato attuale della modalità di risparmio della batteria.
-Description[ka]=გაიარეთ ავთენტიკაცია ელემენტის შენახვის მიმდინარე რეჟიმის მისაღებად.
-Description[lt]=Norint tikrinti akumuliatoriaus saugojimo veikseną, turi būti nustatyta tapatybė.
-Description[nl]=Authenticeren om de huidige status van de conserveringsmodus van de batterij te controleren.
-Description[pl]=Uwierzytelnij, aby odczytaj tryb zarządzania baterią.
-Description[sk]=Overenie totožnosti na zobrazenie aktuálneho režimu ochrany batérie.
-Description[sl]=Avtenticirajte se, da preverite trenutno stanje načina varčevanja baterije.
-Description[tr]=Pil tasarrufu kipinin geçerli durumunu denetlemek için kimliğinizi doğrulayın.
-Description[uk]=Пройдіть розпізнавання для перевірки поточного стану режиму консервації акумулятора.
-Description[x-test]=xxAuthenticate to check the current state of battery conservation mode.xx
-Description[zh_CN]=进行身份验证以检查节电模式的当前状态。
-Description[zh_TW]=認證以查看目前的電池保護模式。
-Policy=yes
-PolicyInactive=yes
-
-[org.kde.powerdevil.chargethresholdhelper.setconservationmode]
-Name=Set battery conservation mode
-Name[ar]=عيّن وضع الحفاظ على البطارية
-Name[bg]=Задаване на режим за пестене на батерията
-Name[ca]=Estableix el mode de conservació de la bateria
-Name[ca@valencia]=Establix el mode de conservació de la bateria
-Name[en_GB]=Set battery conservation mode
-Name[eo]=Agordi baterikonservan reĝimon
-Name[es]=Definir el modo de conservación de la batería
-Name[eu]=Ezarri bateriaren kontserbazio-modua
-Name[fr]=Définir le mode d'économie de la batterie
-Name[he]=הגדרת מצב שימור סוללה
-Name[hu]=Akkumulátorkímélő mód beállítása
-Name[ia]=Fixa le modo de conservation del batteria
-Name[it]=Imposta la modalità di risparmio della batteria
-Name[ka]=ელემენტის შენახვის რეჟიმის დაყენება
-Name[lt]=Nustatyti akumuliatoriaus saugojimo veikseną
-Name[nl]=De conserveringsmodus van de batterij instellen
-Name[pl]=Ustaw tryb zarządzania baterią
-Name[sk]=Nastaviť režim ochrany batérie
-Name[sl]=Nastavi način varčevanja baterije
-Name[tr]=Pil Tasarrufu Kipini Ayarla
-Name[uk]=Встановлення режиму консервації акумулятора
-Name[x-test]=xxSet battery conservation modexx
-Name[zh_CN]=设置节电模式
-Name[zh_TW]=設定電池保護模式
-Description=Authenticate to set the battery conservation mode.
-Description[ar]=استوثق لتعيين وضع الحفاظ على البطارية.
-Description[bg]=Удостоверете автентичността си, за да зададете режима за пестене на батерията.
-Description[ca]=Autenticació per a establir el mode de conservació de la bateria.
-Description[ca@valencia]=Autenticació per a establir el mode de conservació de la bateria.
-Description[en_GB]=Authenticate to set the battery conservation mode.
-Description[eo]=Aŭtentiĝu por meti la bateriokonservan reĝimon.
-Description[es]=Debe autenticarse para definir el modo de conservación de la batería.
-Description[eu]=Kautotu bateriaren kontserbazio-modua ezartzeko.
-Description[fr]=S'authentifier pour définir l'état d'économie de la batterie
-Description[he]=יש לעבור אימות כדי להגדיר את מצב שימור הסוללה.
-Description[hu]=Hitelesítés szükséges az akkumulátorkímélő mód beállításához.
-Description[ia]=Authentica per fixar le modo de conservation de batteria.
-Description[it]=Autenticati per impostare la modalità di risparmio della batteria.
-Description[ka]=გაიარეთ ავთენტიკაცია ელემენტის შენახვის დონის დასაყენებლად.
-Description[lt]=Norint nustatyti akumuliatoriaus saugojimo veikseną, turi būti nustatyta tapatybė.
-Description[nl]=Authenticeren om de conserveringsmodus van de batterij in te stellen.
-Description[pl]=Uwierzytelnij, aby ustawić tryb zarządzania baterią.
-Description[sk]=Overenie totožnosti na nastavenie režimu ochrany batérie.
-Description[sl]=Avtenticirajte se, da bi nastavili način varčevanje baterije.
-Description[tr]=Pil tasarrufu kipini ayarlamak için kimliğinizi doğrulayın.
-Description[uk]=Пройдіть розпізнавання для встановлення режиму консервації акумулятора.
-Description[x-test]=xxAuthenticate to set the battery conservation mode.xx
-Description[zh_CN]=进行身份验证以设置节电模式。
-Description[zh_TW]=認證以設定電池保護模式。
-Policy=auth_admin
-Persistence=session
Index: powerdevil-6.1.0/daemon/chargethresholdhelper.cpp
===================================================================
--- powerdevil-6.1.0.orig/daemon/chargethresholdhelper.cpp
+++ powerdevil-6.1.0/daemon/chargethresholdhelper.cpp
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de>
- * SPDX-FileCopyrightText: 2023 Fabian Arndt <fabian.arndt@root-core.net>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
@@ -17,7 +16,6 @@
#include <QFile>
static const QString s_powerSupplySysFsPath = QStringLiteral("/sys/class/power_supply");
-static const QString s_conservationModeSysFsPath = QStringLiteral("/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode");
static const QString s_chargeStartThreshold = QStringLiteral("charge_control_start_threshold");
static const QString s_chargeEndThreshold = QStringLiteral("charge_control_end_threshold");
@@ -174,56 +172,6 @@ ActionReply ChargeThresholdHelper::setth
return reply;
}
- return ActionReply();
-}
-
-// This handles Lenovo's "battery conservation mode" that limits the threshold to a fixed value
-// This value differs from model to model (most 55-60%, others ~80%) and is unknown (last checked in Kernel 6.3)
-ActionReply ChargeThresholdHelper::getconservationmode(const QVariantMap &args)
-{
- Q_UNUSED(args);
-
- QFile file(s_conservationModeSysFsPath);
- if (!file.open(QIODevice::ReadOnly)) {
- auto reply = ActionReply::HelperErrorReply();
- reply.setErrorDescription(QStringLiteral("Battery conservation mode is not supported"));
- return reply;
- }
-
- int state = 0;
- QTextStream stream(&file);
- stream >> state;
-
- if (state < 0 || state > 1) {
- auto reply = ActionReply::HelperErrorReply();
- reply.setErrorDescription(QStringLiteral("Battery conservation mode is in an invalid state"));
- return reply;
- }
-
- ActionReply reply;
- reply.setData({
- {QStringLiteral("batteryConservationModeEnabled"), !!state}
- });
- return reply;
-}
-
-ActionReply ChargeThresholdHelper::setconservationmode(const QVariantMap &args)
-{
- const bool enabled = args.value(QStringLiteral("batteryConservationModeEnabled"), 0).toBool();
- QFile file(s_conservationModeSysFsPath);
-
- if (!file.open(QIODevice::WriteOnly)) {
- auto reply = ActionReply::HelperErrorReply();
- reply.setErrorDescription(QStringLiteral("Failed to open battery conservation mode file"));
- return reply;
- }
-
- if (file.write(QByteArray::number(enabled)) == -1) {
- auto reply = ActionReply::HelperErrorReply();
- reply.setErrorDescription(QStringLiteral("Failed to set battery conservation mode"));
- return reply;
- }
-
return ActionReply();
}
Index: powerdevil-6.1.0/daemon/chargethresholdhelper.h
===================================================================
--- powerdevil-6.1.0.orig/daemon/chargethresholdhelper.h
+++ powerdevil-6.1.0/daemon/chargethresholdhelper.h
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de>
- * SPDX-FileCopyrightText: 2023 Fabian Arndt <fabian.arndt@root-core.net>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
@@ -22,7 +21,4 @@ public:
public Q_SLOTS:
ActionReply getthreshold(const QVariantMap &args);
ActionReply setthreshold(const QVariantMap &args);
-
- ActionReply getconservationmode(const QVariantMap &args);
- ActionReply setconservationmode(const QVariantMap &args);
};
Index: powerdevil-6.1.0/daemon/dbus/org.kde.Solid.PowerManagement.xml
===================================================================
--- powerdevil-6.1.0.orig/daemon/dbus/org.kde.Solid.PowerManagement.xml
+++ powerdevil-6.1.0/daemon/dbus/org.kde.Solid.PowerManagement.xml
@@ -31,9 +31,6 @@
<method name="hasDualGpu">
<arg type="b" direction="out" />
</method>
- <method name="isBatteryConservationModeEnabled">
- <arg type="b" direction="out" />
- </method>
<method name="chargeStartThreshold">
<arg type="i" direction="out" />
</method>
@@ -108,9 +105,6 @@
<signal name="lidClosedChanged">
<arg type="b" direction="out" />
</signal>
- <signal name="batteryConservationModeChanged">
- <arg type="b" direction="out" />
- </signal>
<signal name="chargeStartThresholdChanged">
<arg type="i" direction="out" />
</signal>
Index: powerdevil-6.1.0/daemon/powerdevilcore.cpp
===================================================================
--- powerdevil-6.1.0.orig/daemon/powerdevilcore.cpp
+++ powerdevil-6.1.0/daemon/powerdevilcore.cpp
@@ -70,7 +70,6 @@ Core::Core(QObject *parent)
discreteGpuJob->start();
readChargeThreshold();
- readBatteryConservationMode();
}
Core::~Core()
@@ -271,7 +270,6 @@ void Core::reparseConfiguration()
}
readChargeThreshold();
- readBatteryConservationMode();
}
QString Core::currentProfile() const
@@ -954,29 +952,6 @@ void Core::readChargeThreshold()
job->start();
}
-void Core::readBatteryConservationMode()
-{
- KAuth::Action action(QStringLiteral("org.kde.powerdevil.chargethresholdhelper.getconservationmode"));
- action.setHelperId(QStringLiteral("org.kde.powerdevil.chargethresholdhelper"));
- KAuth::ExecuteJob *job = action.execute();
- connect(job, &KJob::result, this, [this, job] {
- if (job->error()) {
- qCWarning(POWERDEVIL) << "org.kde.powerdevil.chargethresholdhelper.getconservationmode failed" << job->errorText();
- return;
- }
-
- const auto data = job->data();
- const bool enabled = data.value(QStringLiteral("batteryConservationModeEnabled")).toBool();
- if (m_batteryConservationModeEnabled != enabled) {
- m_batteryConservationModeEnabled = enabled;
- Q_EMIT batteryConservationModeChanged(enabled);
- }
-
- qCDebug(POWERDEVIL) << "Battery conservation mode is" << (enabled ? "enabled" : "disabled");
- });
- job->start();
-}
-
SuspendController *Core::suspendController()
{
return m_suspendController.get();
@@ -1021,11 +996,6 @@ bool Core::hasDualGpu() const
return m_hasDualGpu;
}
-bool Core::isBatteryConservationModeEnabled() const
-{
- return m_batteryConservationModeEnabled;
-}
-
int Core::chargeStartThreshold() const
{
return m_chargeStartThreshold;
Index: powerdevil-6.1.0/daemon/powerdevilcore.h
===================================================================
--- powerdevil-6.1.0.orig/daemon/powerdevilcore.h
+++ powerdevil-6.1.0/daemon/powerdevilcore.h
@@ -105,7 +105,6 @@ public Q_SLOTS:
bool isLidPresent() const;
bool isActionSupported(const QString &actionName);
bool hasDualGpu() const;
- bool isBatteryConservationModeEnabled() const;
int chargeStartThreshold() const;
int chargeStopThreshold() const;
@@ -124,7 +123,6 @@ Q_SIGNALS:
void batteryRemainingTimeChanged(qulonglong time);
void smoothedBatteryRemainingTimeChanged(qulonglong time);
void lidClosedChanged(bool closed);
- void batteryConservationModeChanged(bool enabled);
void chargeStartThresholdChanged(int threshold);
void chargeStopThresholdChanged(int threshold);
@@ -139,7 +137,6 @@ private:
void triggerCriticalBatteryAction();
void readChargeThreshold();
- void readBatteryConservationMode();
/**
* Computes the current global charge percentage.
@@ -150,7 +147,6 @@ private:
friend class Action;
bool m_hasDualGpu;
- bool m_batteryConservationModeEnabled = false;
int m_chargeStartThreshold = 0;
int m_chargeStopThreshold = 100;
Index: powerdevil-6.1.0/kcmodule/profiles/ExternalServiceSettings.cpp
===================================================================
--- powerdevil-6.1.0.orig/kcmodule/profiles/ExternalServiceSettings.cpp
+++ powerdevil-6.1.0/kcmodule/profiles/ExternalServiceSettings.cpp
@@ -1,7 +1,6 @@
/*
* SPDX-FileCopyrightText: 2008-2010 Dario Freddi <drf@kde.org>
* SPDX-FileCopyrightText: 2023 Jakob Petsovits <jpetso@petsovits.com>
- * SPDX-FileCopyrightText: 2024 Fabian Arndt <fabian.arndt@root-core.net>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -23,9 +22,6 @@
#include <QDBusServiceWatcher>
#include <QPointer>
-// debug category for qCInfo()
-#include <powerdevil_debug.h>
-
namespace
{
constexpr int ChargeThresholdUnsupported = -1;
@@ -36,138 +32,81 @@ namespace PowerDevil
ExternalServiceSettings::ExternalServiceSettings(QObject *parent)
: QObject(parent)
- , m_batteryConservationMode(false)
, m_chargeStartThreshold(ChargeThresholdUnsupported)
, m_chargeStopThreshold(ChargeThresholdUnsupported)
- , m_savedBatteryConservationMode(false)
, m_savedChargeStartThreshold(ChargeThresholdUnsupported)
, m_savedChargeStopThreshold(ChargeThresholdUnsupported)
- , m_isBatteryConservationModeSupported(false)
, m_chargeStopThresholdMightNeedReconnect(false)
{
}
-void ExternalServiceSettings::executeChargeThresholdHelperAction(const QString &actionName,
- QWindow *parentWindowForKAuth,
- const QVariantMap &arguments,
- const std::function<void(KAuth::ExecuteJob *job)> callback)
+void ExternalServiceSettings::load(QWindow *parentWindowForKAuth)
{
- KAuth::Action action(QStringLiteral("org.kde.powerdevil.chargethresholdhelper.") + actionName);
+ KAuth::Action action(QStringLiteral("org.kde.powerdevil.chargethresholdhelper.getthreshold"));
action.setHelperId(QStringLiteral("org.kde.powerdevil.chargethresholdhelper"));
action.setParentWindow(parentWindowForKAuth);
- action.setArguments(arguments);
-
KAuth::ExecuteJob *job = action.execute();
+
QPointer thisAlive(this);
QPointer jobAlive(job);
job->exec();
- if (!thisAlive || !jobAlive) {
- qCInfo(POWERDEVIL) << action.name() << "failed: was deleted during job execution";
- return;
- }
-
- if (job->error()) {
- qCInfo(POWERDEVIL) << "KAuth action" << action.name() << "failed:" << job->errorText();
- }
- callback(job);
-}
-
-void ExternalServiceSettings::load(QWindow *parentWindowForKAuth)
-{
- // Battery thresholds (start / stop)
- executeChargeThresholdHelperAction("getthreshold", parentWindowForKAuth, {}, [&](KAuth::ExecuteJob *job) {
- if (job->error()) {
+ if (thisAlive && jobAlive) {
+ if (!job->error()) {
+ const auto data = job->data();
+ setSavedChargeStartThreshold(data.value(QStringLiteral("chargeStartThreshold")).toInt());
+ setSavedChargeStopThreshold(data.value(QStringLiteral("chargeStopThreshold")).toInt());
+ setChargeStopThreshold(m_savedChargeStopThreshold);
+ setChargeStartThreshold(m_savedChargeStartThreshold);
+ } else {
+ qWarning() << "org.kde.powerdevil.chargethresholdhelper.getthreshold failed:" << job->errorText();
setSavedChargeStartThreshold(ChargeThresholdUnsupported);
setSavedChargeStopThreshold(ChargeThresholdUnsupported);
- return;
- }
-
- const auto data = job->data();
- setSavedChargeStartThreshold(data.value(QStringLiteral("chargeStartThreshold")).toInt());
- setSavedChargeStopThreshold(data.value(QStringLiteral("chargeStopThreshold")).toInt());
- setChargeStopThreshold(m_savedChargeStopThreshold);
- setChargeStartThreshold(m_savedChargeStartThreshold);
- });
-
- // Battery Conservation Mode (fixed)
- executeChargeThresholdHelperAction("getconservationmode", parentWindowForKAuth, {}, [&](KAuth::ExecuteJob *job) {
- if (job->error()) {
- setSavedBatteryConservationMode(false);
- m_isBatteryConservationModeSupported = false;
- return;
}
-
- const auto data = job->data();
- setSavedBatteryConservationMode(data.value(QStringLiteral("batteryConservationModeEnabled")).toBool());
- setBatteryConservationMode(m_batteryConservationMode);
- m_isBatteryConservationModeSupported = true;
- });
+ } else {
+ qWarning() << "org.kde.powerdevil.chargethresholdhelper.getthreshold failed: was deleted during job execution";
+ }
}
void ExternalServiceSettings::save(QWindow *parentWindowForKAuth)
{
- // Battery threshold (start / stop)
if ((isChargeStartThresholdSupported() && m_chargeStartThreshold != m_savedChargeStartThreshold)
|| (isChargeStopThresholdSupported() && m_chargeStopThreshold != m_savedChargeStopThreshold)) {
int newChargeStartThreshold = isChargeStartThresholdSupported() ? m_chargeStartThreshold : ChargeThresholdUnsupported;
int newChargeStopThreshold = isChargeStopThresholdSupported() ? m_chargeStopThreshold : ChargeThresholdUnsupported;
- executeChargeThresholdHelperAction("setthreshold",
- parentWindowForKAuth,
- {
- {QStringLiteral("chargeStartThreshold"), newChargeStartThreshold},
- {QStringLiteral("chargeStopThreshold"), newChargeStopThreshold},
- },
- [&](KAuth::ExecuteJob *job) {
- if (job->error()) {
- setChargeStopThreshold(m_savedChargeStopThreshold);
- setChargeStartThreshold(m_savedChargeStartThreshold);
- return;
- }
-
- setSavedChargeStartThreshold(newChargeStartThreshold);
- setSavedChargeStopThreshold(newChargeStopThreshold);
- });
- }
-
- // Battery Conservation Mode (fixed)
- if (isBatteryConservationModeSupported() && m_batteryConservationMode != m_savedBatteryConservationMode) {
- executeChargeThresholdHelperAction("setconservationmode",
- parentWindowForKAuth,
- {
- {QStringLiteral("batteryConservationModeEnabled"), m_batteryConservationMode},
- },
- [&](KAuth::ExecuteJob *job) {
- if (job->error()) {
- setBatteryConservationMode(m_savedBatteryConservationMode);
- return;
- }
-
- setSavedBatteryConservationMode(m_batteryConservationMode);
- });
+ KAuth::Action action(QStringLiteral("org.kde.powerdevil.chargethresholdhelper.setthreshold"));
+ action.setHelperId(QStringLiteral("org.kde.powerdevil.chargethresholdhelper"));
+ action.setArguments({
+ {QStringLiteral("chargeStartThreshold"), newChargeStartThreshold},
+ {QStringLiteral("chargeStopThreshold"), newChargeStopThreshold},
+ });
+ action.setParentWindow(parentWindowForKAuth);
+ KAuth::ExecuteJob *job = action.execute();
+
+ QPointer thisAlive(this);
+ QPointer jobAlive(job);
+ job->exec();
+
+ if (thisAlive && jobAlive) {
+ if (!job->error()) {
+ setSavedChargeStartThreshold(newChargeStartThreshold);
+ setSavedChargeStopThreshold(newChargeStopThreshold);
+ } else {
+ qWarning() << "org.kde.powerdevil.chargethresholdhelper.setthreshold failed:" << job->errorText();
+ }
+ setChargeStopThreshold(m_savedChargeStopThreshold);
+ setChargeStartThreshold(m_savedChargeStartThreshold);
+ } else {
+ qWarning() << "org.kde.powerdevil.chargethresholdhelper.setthreshold failed: was deleted during job execution";
+ }
}
}
bool ExternalServiceSettings::isSaveNeeded() const
{
return (isChargeStartThresholdSupported() && m_chargeStartThreshold != m_savedChargeStartThreshold)
- || (isChargeStopThresholdSupported() && m_chargeStopThreshold != m_savedChargeStopThreshold)
- || (isBatteryConservationModeSupported() && m_batteryConservationMode != m_savedBatteryConservationMode);
-}
-
-bool ExternalServiceSettings::isBatteryConservationModeSupported() const
-{
- return m_isBatteryConservationModeSupported;
-}
-
-void ExternalServiceSettings::setSavedBatteryConservationMode(bool enabled)
-{
- bool wasSavedBatteryConservationModeSupported = isBatteryConservationModeSupported();
- m_savedBatteryConservationMode = enabled;
- if (wasSavedBatteryConservationModeSupported != isBatteryConservationModeSupported()) {
- Q_EMIT isBatteryConservationModeSupportedChanged();
- }
+ || (isChargeStopThresholdSupported() && m_chargeStopThreshold != m_savedChargeStopThreshold);
}
bool ExternalServiceSettings::isChargeStartThresholdSupported() const
@@ -198,21 +137,6 @@ void ExternalServiceSettings::setSavedCh
}
}
-bool ExternalServiceSettings::batteryConservationMode() const
-{
- return m_batteryConservationMode;
-}
-
-void ExternalServiceSettings::setBatteryConservationMode(bool enabled)
-{
- if (enabled == m_batteryConservationMode) {
- return;
- }
- m_batteryConservationMode = enabled;
- Q_EMIT batteryConservationModeChanged();
- Q_EMIT settingsChanged();
-}
-
int ExternalServiceSettings::chargeStartThreshold() const
{
return m_chargeStartThreshold;
Index: powerdevil-6.1.0/kcmodule/profiles/ExternalServiceSettings.h
===================================================================
--- powerdevil-6.1.0.orig/kcmodule/profiles/ExternalServiceSettings.h
+++ powerdevil-6.1.0/kcmodule/profiles/ExternalServiceSettings.h
@@ -1,6 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Jakob Petsovits <jpetso@petsovits.com>
- * SPDX-FileCopyrightText: 2024 Fabian Arndt <fabian.arndt@root-core.net>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -8,7 +7,6 @@
#pragma once
#include <QObject>
-#include <KAuth/ExecuteJob>
class QWindow;
@@ -21,28 +19,23 @@ class ExternalServiceSettings : public Q
Q_PROPERTY(int chargeStartThreshold READ chargeStartThreshold WRITE setChargeStartThreshold NOTIFY chargeStartThresholdChanged)
Q_PROPERTY(int chargeStopThreshold READ chargeStopThreshold WRITE setChargeStopThreshold NOTIFY chargeStopThresholdChanged)
- Q_PROPERTY(int batteryConservationMode READ batteryConservationMode WRITE setBatteryConservationMode NOTIFY batteryConservationModeChanged)
public:
explicit ExternalServiceSettings(QObject *parent);
bool isSaveNeeded() const;
- bool batteryConservationMode() const;
int chargeStartThreshold() const;
int chargeStopThreshold() const;
- bool isBatteryConservationModeSupported() const;
bool isChargeStartThresholdSupported() const;
bool isChargeStopThresholdSupported() const;
-
bool chargeStopThresholdMightNeedReconnect() const;
public Q_SLOTS:
void load(QWindow *parentWindowForKAuth = nullptr);
void save(QWindow *parentWindowForKAuth = nullptr);
- void setBatteryConservationMode(bool);
void setChargeStartThreshold(int);
void setChargeStopThreshold(int);
@@ -50,36 +43,23 @@ Q_SIGNALS:
void settingsChanged();
// settings, which in addition to their own signal also trigger settingsChanged()
- void batteryConservationModeChanged();
void chargeStartThresholdChanged();
void chargeStopThresholdChanged();
// not settings per se, so these don't trigger settingsChanged()
- void isBatteryConservationModeSupportedChanged();
void isChargeStartThresholdSupportedChanged();
void isChargeStopThresholdSupportedChanged();
void chargeStopThresholdMightNeedReconnectChanged();
private:
- void setSavedBatteryConservationMode(bool);
void setSavedChargeStartThreshold(int);
void setSavedChargeStopThreshold(int);
void setChargeStopThresholdMightNeedReconnect(bool);
- void executeChargeThresholdHelperAction(const QString &actionName,
- QWindow *parentWindowForKAuth,
- const QVariantMap &arguments,
- const std::function<void(KAuth::ExecuteJob *job)> callback);
-
- bool m_batteryConservationMode;
int m_chargeStartThreshold;
int m_chargeStopThreshold;
-
- bool m_savedBatteryConservationMode;
int m_savedChargeStartThreshold;
int m_savedChargeStopThreshold;
-
- bool m_isBatteryConservationModeSupported;
bool m_chargeStopThresholdMightNeedReconnect;
};
Index: powerdevil-6.1.0/kcmodule/profiles/PowerKCM.cpp
===================================================================
--- powerdevil-6.1.0.orig/kcmodule/profiles/PowerKCM.cpp
+++ powerdevil-6.1.0/kcmodule/profiles/PowerKCM.cpp
@@ -151,7 +151,6 @@ PowerKCM::PowerKCM(QObject *parent, cons
this,
&PowerKCM::isChargeStartThresholdSupportedChanged);
connect(m_externalServiceSettings, &ExternalServiceSettings::isChargeStopThresholdSupportedChanged, this, &PowerKCM::isChargeStopThresholdSupportedChanged);
- connect(m_externalServiceSettings, &ExternalServiceSettings::isBatteryConservationModeSupportedChanged, this, &PowerKCM::isBatteryConservationModeSupportedChanged);
connect(m_externalServiceSettings,
&ExternalServiceSettings::chargeStopThresholdMightNeedReconnectChanged,
this,
@@ -291,11 +290,6 @@ void PowerKCM::setSupportsBatteryProfile
Q_EMIT supportsBatteryProfilesChanged();
}
-bool PowerKCM::isBatteryConservationModeSupported() const
-{
- return m_externalServiceSettings->isBatteryConservationModeSupported();
-}
-
bool PowerKCM::isChargeStartThresholdSupported() const
{
return m_externalServiceSettings->isChargeStartThresholdSupported();
Index: powerdevil-6.1.0/kcmodule/profiles/PowerKCM.h
===================================================================
--- powerdevil-6.1.0.orig/kcmodule/profiles/PowerKCM.h
+++ powerdevil-6.1.0/kcmodule/profiles/PowerKCM.h
@@ -65,7 +65,6 @@ class PowerKCM : public KQuickManagedCon
Q_PROPERTY(bool isLidPresent READ isLidPresent NOTIFY isLidPresentChanged)
Q_PROPERTY(bool isPowerButtonPresent READ isPowerButtonPresent NOTIFY isPowerButtonPresentChanged)
- Q_PROPERTY(bool isBatteryConservationModeSupported READ isBatteryConservationModeSupported NOTIFY isBatteryConservationModeSupportedChanged)
Q_PROPERTY(bool isChargeStartThresholdSupported READ isChargeStartThresholdSupported NOTIFY isChargeStartThresholdSupportedChanged)
Q_PROPERTY(bool isChargeStopThresholdSupported READ isChargeStopThresholdSupported NOTIFY isChargeStopThresholdSupportedChanged)
Q_PROPERTY(bool chargeStopThresholdMightNeedReconnect READ chargeStopThresholdMightNeedReconnect NOTIFY chargeStopThresholdMightNeedReconnectChanged)
@@ -97,7 +96,6 @@ public:
bool isLidPresent() const;
bool isPowerButtonPresent() const;
- bool isBatteryConservationModeSupported() const;
bool isChargeStartThresholdSupported() const;
bool isChargeStopThresholdSupported() const;
bool chargeStopThresholdMightNeedReconnect() const;
@@ -127,7 +125,6 @@ Q_SIGNALS:
void isLidPresentChanged();
void isPowerButtonPresentChanged();
- void isBatteryConservationModeSupportedChanged();
void isChargeStartThresholdSupportedChanged();
void isChargeStopThresholdSupportedChanged();
void chargeStopThresholdMightNeedReconnectChanged();
Index: powerdevil-6.1.0/kcmodule/profiles/ui/GlobalConfig.qml
===================================================================
--- powerdevil-6.1.0.orig/kcmodule/profiles/ui/GlobalConfig.qml
+++ powerdevil-6.1.0/kcmodule/profiles/ui/GlobalConfig.qml
@@ -221,18 +221,7 @@ Kirigami.ScrollablePage {
id: chargeLimitHeader
Kirigami.FormData.label: i18nc("@title:group", "Charge Limit")
Kirigami.FormData.isSection: true
- visible: chargeStopThresholdSpin.visible || chargeStartThresholdSpin.visible || batteryConservationModeCheck.visible
- }
-
- QQC2.CheckBox {
- id: batteryConservationModeCheck
- visible: kcm.isBatteryConservationModeSupported
- checked: externalSettings.batteryConservationMode
- onToggled: externalSettings.batteryConservationMode = checked
-
- Kirigami.FormData.label: i18nc("@label:checkbox", "&Battery protection:")
- text: i18nc("@text:checkbox", "Limit the maximum battery charge")
- Accessible.name: text
+ visible: chargeStopThresholdSpin.visible || chargeStartThresholdSpin.visible
}
QQC2.SpinBox {
@@ -330,8 +319,7 @@ Kirigami.ScrollablePage {
Kirigami.FormData.isSection: true
// iFixit suggests keeping the charge between 40-80%, Battery University lists 25-85% as a decent tradeoff.
// Show this reminder only when high charge thresholds are configured.
- visible: (chargeLimitHeader.visible && !chargeStopThresholdReconnectMessage.visible && chargeStopThresholdSpin.value > 85)
- || (batteryConservationModeCheck.visible && !batteryConservationModeCheck.checked)
+ visible: chargeLimitHeader.visible && !chargeStopThresholdReconnectMessage.visible && chargeStopThresholdSpin.value > 85
implicitWidth: Kirigami.Units.gridUnit * 16
text: i18nc("@info", "Regularly charging the battery close to 100%, or fully discharging it, may accelerate deterioration of battery health. By limiting the maximum battery charge, you can help extend the battery lifespan.")
}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:27f995bce6f27e35b78e0c232f8dee8fba50fb91d7b3afd117583bdb79a12fd4
size 799760

View File

@ -1,16 +0,0 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEE4KPrIC+OV1KOE+cv11dEg7tXsY0FAmZM0QUACgkQ11dEg7tX
sY11aA/+NIcLppTb9ACn9hH66XbhY9BjSc2Im9xg8ZVmgaDIlYm6+juTXMEoatOI
9dqPe0KfOcZU06Qi0FwxMotRw9uIE52AGxoFQJlKCCcuQrrK+6/aF8NKe8XUdzdf
/+V7NXKakKGaOophAPw13L7Wk7LXKEFOiWO7KJpRJZ/pix1OSlSK9UR0fnUkmpe8
8ts33wlogB92onNGS7fk4klB6SiJm8kGBWVfgmPz6EI4yii+hoKXxGNVwPgq59gA
4iMCAt1vMFQ5bodP/W5EZ0IxFx3Pwpx/VbtJikV1JHzcvuJhKJiQ0AtHY/jWxUe9
keQDuToFhvOGOYrTpC6H9NMBoUi4Uimv2WSzWwhB1jNddBUQx/fmeLp8fTZyuqsi
+XIUPJzOuOaKUnk0GSUsuwYcTiA+RqEfzRGC8ARx2JmCuzOGs/3k0z1R4Zc/ngeb
CgdiEZAADMqFtO3YCHlsnxzy6rwWETrJZGsouSyDJf1cGIxOt74D2A7xDODxkrgY
6PLD7t7tCUqqYFD9Vbi4adAFddXYjQYdr5YPFVk4Mz91GA/pB8HmyEthX+c6752S
tHedas/LBbsGes2hFLx3B355pvNy4CvxIYCKndLjGGqaMZ0L+bk8HEuyMm7x7+Fa
d2z7Cvdp5h5y2WJ0VGYhD4hEPGxjEjr2LJCei3l22GUpRgv0rtg=
=uhEx
-----END PGP SIGNATURE-----

3
powerdevil-6.1.0.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:445b2a5366bc1d64b04547efe6e713b75a2d3309fe4727e9edf6157be6dd4580
size 961412

View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIyBAABCgAdFiEE4KPrIC+OV1KOE+cv11dEg7tXsY0FAmZqzAsACgkQ11dEg7tX
sY0+RQ/455BDBUWMCeMpFvREcQ1y9+jl7JnPLNLbuIQaRgyFmBlmnadEikzR64Hb
pfmuC7vB41ycvZHZgsPpK4MnGun+9NpqFQRMGvdSPL+MdutRHqSraIDs5obWEwm8
hhi2B7EFofhmX3wZQ+l8sWHbwM2e7V/DbyKpb83LgAdLzGW5o+n13l/r3gFWR5Mk
C7QqVLJh52ifvgRwYLQLY530FtA8ckVM1KuArKruQ7r2Xkezg0Sm5/WPIRYmmNmE
cG3evaw1RvoI8nVSOHmKytuU6RRcF+jq1eUhE9fqSYvklbGzZhu2LURcCVqFjVN+
yITdnBpva+RRDIOO52R6dDuNUi2JxuHZFqk8+Nrp6FJ3PkzbSfc25Kun7rMhZG/G
SnZbSE06flppMNNJ7PQlzTmQ+Ns83m6GpS4dyEIeOI9xhL43hl+k2tM/GGkHCORe
5fkE5YB+tMWBHmgeDqfoH4MeNXj1Qk/pjDd89KI36gdA5Yd5Rjrd7kFIt/HEuVUP
qtLwmRqAjXkBawb3bB9mn5YeQzfOBHCAebpbsD3pv0bTQfIuw1deGowFEspupa1M
bDV6lNW7x/6MzMhyodAa+6JNeJ+8iG6GheHd1I/Vv25uYdLdkP2o7NPC1iEgCH5P
y2yxKaD1lwohKZ6UofVxYqT27XUsL54YRqaWmREAtjLab9+rEA==
=a7Py
-----END PGP SIGNATURE-----

View File

@ -1,3 +1,30 @@
-------------------------------------------------------------------
Mon Jun 17 09:43:38 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Add patch to revert feature until new polkit rules got whitelisted:
* 0001-Revert-Added-setting-for-battery-conservation-mode-L.patch
-------------------------------------------------------------------
Thu Jun 13 10:58:59 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.1.0:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.1.0
- Changes since 6.0.90:
* update version for new release
* daemon/controllers/kwinbrightness: remove brightness control of disabled screens
* daemon: Don't disconnect from a null object (kde#487647)
* OSD: Close on focus lost
* OSD: start cleanup timer
-------------------------------------------------------------------
Sat May 25 11:20:12 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.90:
* New feature release
* For more details see https://kde.org/announcements/plasma/6/6.0.90
- Too many changes to list here
-------------------------------------------------------------------
Wed May 22 07:43:21 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>

View File

@ -16,13 +16,13 @@
#
%define kf6_version 6.0.0
%define kf6_version 6.2.0
%define qt6_version 6.6.0
%define rname powerdevil
%bcond_without released
Name: powerdevil6
Version: 6.0.5
Version: 6.1.0
Release: 0
# Full Plasma 6 version (e.g. 6.0.0)
%{!?_plasma6_bugfix: %define _plasma6_bugfix %{version}}
@ -31,11 +31,13 @@ Release: 0
Summary: KDE Power Management module
License: GPL-2.0-or-later
URL: https://www.kde.org
Source: https://download.kde.org/stable/plasma/%{version}/%{rname}-%{version}.tar.xz
Source: %{rname}-%{version}.tar.xz
%if %{with released}
Source1: https://download.kde.org/stable/plasma/%{version}/%{rname}-%{version}.tar.xz.sig
Source1: %{rname}-%{version}.tar.xz.sig
Source2: plasma.keyring
%endif
# PATCH-BREAK-OPENSUSE waiting for review (boo#1226424)
Patch1: 0001-Revert-Added-setting-for-battery-conservation-mode-L.patch
BuildRequires: kf6-extra-cmake-modules >= %{kf6_version}
# Needed by FindLibcap.cmake
BuildRequires: libcap-progs
@ -136,8 +138,6 @@ rm -rv %{buildroot}%{_kf6_libdir}/libpowerdevil{core,configcommonprivate}.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_powerprofileaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_runscriptaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_suspendsessionaction.so
%dir %{_kf6_plugindir}/kf6/powerdevil/
%{_kf6_plugindir}/kf6/powerdevil/powerdevilupowerbackend.so
%{_kf6_sharedir}/dbus-1/services/org.kde.powerdevil.powerProfileOsdService.service
%{_kf6_sharedir}/dbus-1/system-services/org.kde.powerdevil.backlighthelper.service
%{_kf6_sharedir}/dbus-1/system-services/org.kde.powerdevil.chargethresholdhelper.service