git: 324d77671c2b - main - sysutils/plasma6-powerdevil: Backport upstream fix for KDE BUG 518513

From: Max Brazhnikov <makc_at_FreeBSD.org>
Date: Wed, 23 Sep 2026 11:36:20 UTC
The branch main has been updated by makc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=324d77671c2b2ca77c8d5ce115d603d65f598e4a

commit 324d77671c2b2ca77c8d5ce115d603d65f598e4a
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2026-09-23 11:35:56 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2026-09-23 11:35:56 +0000

    sysutils/plasma6-powerdevil: Backport upstream fix for KDE BUG 518513
    
    to avoid low battery alerts for unknown percentages.
---
 sysutils/plasma6-powerdevil/Makefile               |  1 +
 .../files/patch-daemon_powerdevilcore.cpp          | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/sysutils/plasma6-powerdevil/Makefile b/sysutils/plasma6-powerdevil/Makefile
index d030934be580..646781998829 100644
--- a/sysutils/plasma6-powerdevil/Makefile
+++ b/sysutils/plasma6-powerdevil/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	powerdevil
 DISTVERSION=	${KDE_PLASMA_VERSION}
+PORTREVISION=	1
 CATEGORIES=	sysutils kde kde-plasma
 
 MAINTAINER=	kde@FreeBSD.org
diff --git a/sysutils/plasma6-powerdevil/files/patch-daemon_powerdevilcore.cpp b/sysutils/plasma6-powerdevil/files/patch-daemon_powerdevilcore.cpp
new file mode 100644
index 000000000000..e0eba2e1dbf1
--- /dev/null
+++ b/sysutils/plasma6-powerdevil/files/patch-daemon_powerdevilcore.cpp
@@ -0,0 +1,22 @@
+From 54f8a4a848fa02d06fefc5543f35224eef73670c Mon Sep 17 00:00:00 2001
+From: Matthias Kurz <m.kurz@irregular.at>
+Date: Wed, 19 Aug 2026 17:51:12 +0200
+Subject: [PATCH] Avoid low battery alerts for unknown percentages
+
+Peripheral batteries with an unavailable charge return a negative percentage. Exclude all non-positive values from low-battery notification handling so an unknown device cannot be mistaken for an empty one.
+
+--- daemon/powerdevilcore.cpp.orig	2026-09-08 11:00:22 UTC
++++ daemon/powerdevilcore.cpp
+@@ -521,9 +521,9 @@ bool Core::emitBatteryChargePercentNotification(int cu
+             return false;
+         }
+ 
+-        // if you leave the device out of reach or it has not been initialized yet
+-        // it won't be "there" and report 0%, don't show anything in this case
+-        if (!b->isPresent() || b->chargePercent() == 0) {
++        // If you leave the device out of reach or it has not been initialized yet,
++        // it won't be "there" and can report an empty or unknown percentage.
++        if (!b->isPresent() || b->chargePercent() <= 0) {
+             return false;
+         }
+