SHA256
1
0
forked from pool/powerdevil6
Christophe Marin 2024-07-03 06:31:44 +00:00 committed by Git OBS Bridge
commit dceb88e1d3
8 changed files with 1131 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,768 @@
From 66422f7144b23123020e1d7a64b66ee70c77bb63 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Tue, 2 Jul 2024 21:02:15 +0200
Subject: [PATCH] Revert "Added setting for battery conservation mode (Lenovo)"
This reverts commit 7da820f5ba64766b15c1451ad0fbed3b714ed307.
This reverts commit 53f688de8eff37a52efed55b52d9e51f5217a185.
---
daemon/chargethreshold_helper_actions.actions | 124 --------------
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(+), 380 deletions(-)
diff --git a/daemon/chargethreshold_helper_actions.actions b/daemon/chargethreshold_helper_actions.actions
index 19587346..ff5299e8 100644
--- a/daemon/chargethreshold_helper_actions.actions
+++ b/daemon/chargethreshold_helper_actions.actions
@@ -235,127 +235,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[cs]=Zkontrolovat režim šetření baterie
-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[is]=Athuga sparnaðarsnið rafhlöðu
-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[sv]=Kontrollera batteriets konserveringsläge
-Name[ta]=மின்கல சேமிப்பு பயன்முறையின் நிலைகாண்
-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[cs]=Ověřte totožnost abyste zjistili stav režimu šetření baterie.
-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[is]=Auðkenndu þig til að sjá núverandi sparnaðarsnið rafhlöðu.
-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[sv]=Ange behörighet för att se nuvarande tillstånd hos batteriets konserveringsläge.
-Description[ta]=மின்கல சேமிப்பு பயன்முறையின் தற்போதைய நிலையைக் காண சான்றளிக்கவும்.
-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[cs]=Nastavte režim šetření baterie
-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[is]=Stilla sparnaðarsnið rafhlöðu
-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[sv]=Ställ in batteriets konserveringsläge
-Name[ta]=மின்கல சேமிப்பு பயன்முறையை அமை
-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[cs]=Ověřte totožnost pro nastavení režimu šetření baterie.
-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[is]=Auðkenndu þig til að stilla sparnaðarsnið rafhlöðu.
-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[sv]=Ange behörighet för att ställa in batteriets konserveringsläge.
-Description[ta]=மின்கல சேமிப்பு பயன்முறையை அமைக்க சான்றளிக்கவும்.
-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
diff --git a/daemon/chargethresholdhelper.cpp b/daemon/chargethresholdhelper.cpp
index fb801d92..6c4e0afe 100644
--- a/daemon/chargethresholdhelper.cpp
+++ b/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");
@@ -177,56 +175,6 @@ ActionReply ChargeThresholdHelper::setthreshold(const QVariantMap &args)
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();
-}
-
KAUTH_HELPER_MAIN("org.kde.powerdevil.chargethresholdhelper", ChargeThresholdHelper)
#include "moc_chargethresholdhelper.cpp"
diff --git a/daemon/chargethresholdhelper.h b/daemon/chargethresholdhelper.h
index b0f93722..fd5a8221 100644
--- a/daemon/chargethresholdhelper.h
+++ b/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);
};
diff --git a/daemon/dbus/org.kde.Solid.PowerManagement.xml b/daemon/dbus/org.kde.Solid.PowerManagement.xml
index 18240feb..5cb5a0ac 100644
--- a/daemon/dbus/org.kde.Solid.PowerManagement.xml
+++ b/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>
diff --git a/daemon/powerdevilcore.cpp b/daemon/powerdevilcore.cpp
index 915ca0ad..dec3aa41 100644
--- a/daemon/powerdevilcore.cpp
+++ b/daemon/powerdevilcore.cpp
@@ -70,7 +70,6 @@ Core::Core(QObject *parent)
discreteGpuJob->start();
readChargeThreshold();
- readBatteryConservationMode();
}
Core::~Core()
@@ -266,7 +265,6 @@ void Core::reparseConfiguration()
}
readChargeThreshold();
- readBatteryConservationMode();
}
QString Core::currentProfile() const
@@ -949,29 +947,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();
@@ -1017,11 +992,6 @@ bool Core::hasDualGpu() const
return m_hasDualGpu;
}
-bool Core::isBatteryConservationModeEnabled() const
-{
- return m_batteryConservationModeEnabled;
-}
-
int Core::chargeStartThreshold() const
{
return m_chargeStartThreshold;
diff --git a/daemon/powerdevilcore.h b/daemon/powerdevilcore.h
index 02fe8430..634ee7ff 100644
--- a/daemon/powerdevilcore.h
+++ b/daemon/powerdevilcore.h
@@ -106,7 +106,6 @@ public Q_SLOTS:
bool isLidPresent() const;
bool isActionSupported(const QString &actionName);
bool hasDualGpu() const;
- bool isBatteryConservationModeEnabled() const;
int chargeStartThreshold() const;
int chargeStopThreshold() const;
@@ -125,7 +124,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;
diff --git a/kcmodule/profiles/ExternalServiceSettings.cpp b/kcmodule/profiles/ExternalServiceSettings.cpp
index 70f2953b..7e704cc2 100644
--- a/kcmodule/profiles/ExternalServiceSettings.cpp
+++ b/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_savedBatteryConservationMode);
- 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::setSavedChargeStopThreshold(int threshold)
}
}
-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;
diff --git a/kcmodule/profiles/ExternalServiceSettings.h b/kcmodule/profiles/ExternalServiceSettings.h
index c9205273..01f3525f 100644
--- a/kcmodule/profiles/ExternalServiceSettings.h
+++ b/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 QObject
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;
};
diff --git a/kcmodule/profiles/PowerKCM.cpp b/kcmodule/profiles/PowerKCM.cpp
index bd999ff8..85184994 100644
--- a/kcmodule/profiles/PowerKCM.cpp
+++ b/kcmodule/profiles/PowerKCM.cpp
@@ -151,7 +151,6 @@ PowerKCM::PowerKCM(QObject *parent, const KPluginMetaData &metaData)
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::setSupportsBatteryProfiles(bool supportsBatteryProfiles)
Q_EMIT supportsBatteryProfilesChanged();
}
-bool PowerKCM::isBatteryConservationModeSupported() const
-{
- return m_externalServiceSettings->isBatteryConservationModeSupported();
-}
-
bool PowerKCM::isChargeStartThresholdSupported() const
{
return m_externalServiceSettings->isChargeStartThresholdSupported();
diff --git a/kcmodule/profiles/PowerKCM.h b/kcmodule/profiles/PowerKCM.h
index 36814ad0..efcfcb18 100644
--- a/kcmodule/profiles/PowerKCM.h
+++ b/kcmodule/profiles/PowerKCM.h
@@ -65,7 +65,6 @@ class PowerKCM : public KQuickManagedConfigModule
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();
diff --git a/kcmodule/profiles/ui/GlobalConfig.qml b/kcmodule/profiles/ui/GlobalConfig.qml
index 454f6326..511824ac 100644
--- a/kcmodule/profiles/ui/GlobalConfig.qml
+++ b/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.")
}
--
2.45.2

BIN
plasma.keyring Normal file

Binary file not shown.

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

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

View File

@ -0,0 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEE4KPrIC+OV1KOE+cv11dEg7tXsY0FAmaEDG4ACgkQ11dEg7tX
sY1n4A/+Nh+aiRxWHtdTuwY+0sH2RSZ3v03Q0fWigtQ6yKHW1hkL8Rgfdw1dNPng
zLfts+O2Qsjg3TKNbwr3Mi8jcb91e14RbcrA06NbNoiIF/9FbCNlpEjxTXP7veNd
y19H8ByQxuz8Xe7GDj6LCp9BhaD0nMSMONa1aicFV/l+80eeYM33dE5tpBXi/QnO
b+sUmBD7816GcWvzxxz5/Jor6BrzGxTBq4Z2BYTfCxSkwXqGRT4EXzn1MY7cuynd
LDGLDmKwjqhr7d2expvXsOcdMTssR7Go2HHM5Hil9M/Shqjl+SQq3u3AhKOx0jeh
5pH8D+Y0QE7Rv4vcxkZm+GWv+lSFJ8rdwH4vLr7Df/EkDOu22L+m6Ko11/GYXf9p
56TTtuGqPc4fx+brNm3ZyDYy1h2c/T4lGCHx7qW+qWiqRTcabIEkNLibFrnoffsd
GHfBPimtJGsk9IUXe89B0ZF+STJZ2Wi+GbZ3kyvS/jwQ4Tin6fZZyKce3wLH0BMt
GtVfJ6qRYv1DUOaTOD2C2FvWjxHx+cSF8ou143SUryV9hJk0kvbERhaooeZhQAOC
7jq5RcT8wB8B9Y65VOSrFELY5exUJMrQiyxQdUXDO3PG285QidXGgAwIzFaVTEpF
EMW2CbwjBHO3bp9NIJrliUR5fGMKxyT87wzF1MXQWyw6j1Y+cms=
=em90
-----END PGP SIGNATURE-----

160
powerdevil6.changes Normal file
View File

@ -0,0 +1,160 @@
-------------------------------------------------------------------
Tue Jul 2 17:34:34 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.1.2:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.1.2
- Changes since 6.1.1:
* daemon/controllers: Reintroduce a mutex around ddca_open_display2() (kde#489169)
* update version for new release
* ddcutildisplay: give some time before changing brightness after the monitor resumes
* core: reload actions on brightness controller changes
* update version for new release
- Rebase 0001-Revert-Added-setting-for-battery-conservation-mode-L.patch
-------------------------------------------------------------------
Tue Jun 25 17:15:54 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.1.1:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.1.1
- Changes since 6.1.0:
* update version for new release
* Fix initial UI state of Battery protection setting (kde#488954)
* daemon: Limit KAuth backlighthelper calls to only one at a time (kde#481003)
* skip ddcutil initialization when POWERDEVIL_NO_DDCUTIL is set
* update version for new release
- Rebase 0001-Revert-Added-setting-for-battery-conservation-mode-L.patch
-------------------------------------------------------------------
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>
- Update to 6.0.5:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.0.5
- Changes since 6.0.4:
* update version for new release
* kcmodule: Hide profile load/unload fields if battery profiles are absent
* [osd] Force Plasma styling (kde#480254)
-------------------------------------------------------------------
Wed May 15 08:13:04 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Recommend ddcutil-i2c-udev-rules (boo#1224197)
-------------------------------------------------------------------
Wed Apr 17 08:13:55 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.4:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.0.4
- Changes since 6.0.3:
* update version for new release
* actions/dimdisplay: Improve log messages
* actions/dimdisplay: Don't dim when screen changes are inhibited
* daemon: Avoid constantly locking ddcutil display handles (kde#481793)
* daemon: Store label for DDCutilBrightness as QString directly
* actions/handlebuttonevents: Require lid-open again to track kb brightness (kde#482306)
* update version for new release
-------------------------------------------------------------------
Tue Mar 26 18:06:58 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.3:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.0.3
- Changes since 6.0.2:
* update version for new release
* kcmodule: Don't crash when a configured button action is unsupported (kde#482668)
-------------------------------------------------------------------
Wed Mar 13 09:10:38 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.2:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.0.2
- Changes since 6.0.1:
* update version for new release
* actions/dpms: Ignore turn-off triggers when action is disabled (kde#481308,kde#482077)
* actions/powerprofile: guard against empty profiles list in readProperties (kde#483216)
* Check if idle inhibitor is active before blanking the screen (kde#482141)
* Make OSD labels translatable
* update version for new release
-------------------------------------------------------------------
Wed Mar 6 08:40:34 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.1:
* New bugfix release
* For more details see https://kde.org/announcements/plasma/6/6.0.1
- Changes since 6.0.0:
* update version for new release
* [dimdisplay] Respect profile configurations
-------------------------------------------------------------------
Mon Mar 4 18:52:31 UTC 2024 - Christophe Marin <christophe@krop.fr>
- Add Provides/Obsoletes to replace Plasma 5
-------------------------------------------------------------------
Wed Feb 21 18:36:41 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 6.0.0:
* New bugfix release
* Release announcement not available yet
- Changes since 5.93.0:
* update version for new release
* kcmodule: Remove separator line now that NavigationTabBar provides it
* kbd backlight: Fix double brightness restore on LidOpen-resume
* update version for new release
-------------------------------------------------------------------
Wed Jan 31 17:38:28 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 5.93.0 (6.0 RC 2):
* New bugfix release
* See https://kde.org/announcements/megarelease/6/rc2/ for details
- Changes since 5.92.0:
* RC 1 version dep
* add a version for dependencies so it does not break CI https://invent.kde.org/plasma/bluedevil/-/merge_requests/156
* Allow disabling DDC brightness via env variable
* ddcutil: skip invalid displays (kde#476375)
-------------------------------------------------------------------
Mon Jan 15 21:09:14 UTC 2024 - Fabian Vogt <fabian@ritter-vogt.de>
- Update to 5.92.0 (6.0 RC 1)
* For more details please see:
https://kde.org/announcements/megarelease/6/rc1/
-------------------------------------------------------------------
Mon Jul 10 09:53:19 UTC 2023 - Christophe Marin <christophe@krop.fr>
- Init powerdevil6

160
powerdevil6.spec Normal file
View File

@ -0,0 +1,160 @@
#
# spec file for package powerdevil6
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define kf6_version 6.2.0
%define qt6_version 6.6.0
%define rname powerdevil
%bcond_without released
Name: powerdevil6
Version: 6.1.2
Release: 0
# Full Plasma 6 version (e.g. 6.0.0)
%{!?_plasma6_bugfix: %define _plasma6_bugfix %{version}}
# Latest ABI-stable Plasma (e.g. 6.0 in KF6, but 6.0.80 in KUF)
%{!?_plasma6_version: %define _plasma6_version %(echo %{_plasma6_bugfix} | awk -F. '{print $1"."$2}')}
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
%if %{with released}
Source1: https://download.kde.org/stable/plasma/%{version}/%{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
BuildRequires: pkgconfig
BuildRequires: qt6-gui-private-devel >= %{qt6_version}
BuildRequires: systemd-rpm-macros
BuildRequires: cmake(KF6Auth) >= %{kf6_version}
BuildRequires: cmake(KF6Config) >= %{kf6_version}
BuildRequires: cmake(KF6Crash) >= %{kf6_version}
BuildRequires: cmake(KF6DBusAddons) >= %{kf6_version}
BuildRequires: cmake(KF6DocTools) >= %{kf6_version}
BuildRequires: cmake(KF6GlobalAccel) >= %{kf6_version}
BuildRequires: cmake(KF6I18n) >= %{kf6_version}
BuildRequires: cmake(KF6IdleTime) >= %{kf6_version}
BuildRequires: cmake(KF6KCMUtils) >= %{kf6_version}
BuildRequires: cmake(KF6KIO) >= %{kf6_version}
BuildRequires: cmake(KF6KirigamiPlatform) >= %{kf6_version}
BuildRequires: cmake(KF6Notifications) >= %{kf6_version}
BuildRequires: cmake(KF6NotifyConfig) >= %{kf6_version}
BuildRequires: cmake(KF6Screen) >= %{_plasma6_bugfix}
BuildRequires: cmake(KF6Solid) >= %{kf6_version}
BuildRequires: cmake(KF6XmlGui) >= %{kf6_version}
BuildRequires: cmake(LibKWorkspace) >= %{_plasma6_bugfix}
BuildRequires: cmake(PlasmaActivities) >= %{_plasma6_bugfix}
BuildRequires: cmake(Qt6DBus) >= %{qt6_version}
BuildRequires: cmake(Qt6Widgets) >= %{qt6_version}
BuildRequires: pkgconfig(ddcutil)
BuildRequires: pkgconfig(libcap)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(xcb)
BuildRequires: pkgconfig(xcb-dpms)
BuildRequires: pkgconfig(xcb-randr)
Requires: kf6-kidletime-plugins
#PrepareForSleep is added to systemd 198, and with Plasma 5.2, will be unconditionaly called
Requires: systemd >= 198
%requires_ge plasma6-workspace-libs
Provides: powerdevil5 = %{version}
Obsoletes: powerdevil5 < %{version}
Obsoletes: powerdevil5-lang < %{version}
# Needed for battery / brightness detection
Recommends: upower
# For i2c dev handling and permissions
Recommends: ddcutil-i2c-udev-rules
# For switching power profiles
Recommends: power-profiles-daemon
%description
KDE Power Management module. Provides kded daemon, DBus helper and KCM for
configuring Power settings.
%lang_package
%prep
%autosetup -p1 -n %{rname}-%{version}
%build
%cmake_kf6
%kf6_build
%install
%kf6_install
%find_lang %{name} --all-name --with-html
rm -rv %{buildroot}%{_kf6_libdir}/libpowerdevil{core,configcommonprivate}.so
%post
%ldconfig
%{systemd_user_post plasma-powerdevil.service plasma-powerprofile-osd.service}
%preun
%{systemd_user_preun plasma-powerdevil.service plasma-powerprofile-osd.service}
%postun
%ldconfig
%{systemd_user_postun plasma-powerdevil.service plasma-powerprofile-osd.service}
%files
%license COPYING*
%doc %{_kf6_htmldir}/en/kcontrol/
%{_kf6_applicationsdir}/kcm_powerdevilprofilesconfig.desktop
%{_kf6_configdir}/autostart/powerdevil.desktop
%{_kf6_dbuspolicydir}/org.kde.powerdevil.backlighthelper.conf
%{_kf6_dbuspolicydir}/org.kde.powerdevil.discretegpuhelper.conf
%{_kf6_debugdir}/powerdevil.categories
%{_kf6_libdir}/libpowerdevilconfigcommonprivate.so.*
%{_kf6_libdir}/libpowerdevilcore.so.*
%{_kf6_notificationsdir}/powerdevil.notifyrc
%{_kf6_plugindir}/plasma/kcms/systemsettings/kcm_powerdevilprofilesconfig.so
%dir %{_kf6_plugindir}/powerdevil/
%dir %{_kf6_plugindir}/powerdevil/action
%{_kf6_plugindir}/powerdevil/action/powerdevil_brightnesscontrolaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_dimdisplayaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_dpmsaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_handlebuttoneventsaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_keyboardbrightnesscontrolaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_powerprofileaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_runscriptaction.so
%{_kf6_plugindir}/powerdevil/action/powerdevil_suspendsessionaction.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
%{_kf6_sharedir}/dbus-1/system-services/org.kde.powerdevil.discretegpuhelper.service
%{_kf6_sharedir}/dbus-1/system.d/org.kde.powerdevil.chargethresholdhelper.conf
%{_kf6_sharedir}/polkit-1/actions/org.kde.powerdevil.backlighthelper.policy
%{_kf6_sharedir}/polkit-1/actions/org.kde.powerdevil.chargethresholdhelper.policy
%{_kf6_sharedir}/polkit-1/actions/org.kde.powerdevil.discretegpuhelper.policy
%{_kf6_libexecdir}/kauth/backlighthelper
%{_kf6_libexecdir}/kauth/chargethresholdhelper
%{_kf6_libexecdir}/kauth/discretegpuhelper
%{_libexecdir}/org_kde_powerdevil
%{_libexecdir}/power_profile_osd_service
%{_userunitdir}/plasma-powerdevil.service
%{_userunitdir}/plasma-powerprofile-osd.service
%files lang -f %{name}.lang
%exclude %{_kf6_htmldir}/en/kcontrol
%changelog