From 2a83c5c69b33779050707d65211e3fa126442e20 Mon Sep 17 00:00:00 2001 From: bbedward Date: Wed, 21 Oct 2026 13:59:43 -0400 Subject: [PATCH] battery: throttle pulse animation to 20fps ref #3849 (cherry picked from commit 1b59a474dd0d33f4aeb71d1f5b545629f80eef16) --- quickshell/Modules/DBar/Widgets/Battery.qml | 28 ++++++++------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/quickshell/Modules/DBar/Widgets/Battery.qml b/quickshell/Modules/DBar/Widgets/Battery.qml index b141ecff7..6bf639eb9 100644 --- a/quickshell/Modules/DBar/Widgets/Battery.qml +++ b/quickshell/Modules/DBar/Widgets/Battery.qml @@ -39,26 +39,20 @@ BasePill { return Qt.rgba(from.r + (to.r - from.r) * progress, from.g + (to.g - from.g) * progress, from.b + (to.b - from.b) * progress, from.a + (to.a - from.a) * progress); } - SequentialAnimation on criticalPulse { + property int criticalTick: 0 + + // Stepped on purpose: an Animation repaints the bar at the full refresh rate. + Timer { + interval: 50 + repeat: true running: battery.critical && battery.surfaceLive && !SettingsData.reduceMotion - loops: Animation.Infinite onRunningChanged: { - if (!running) - battery.criticalPulse = 0; + battery.criticalTick = 0; + battery.criticalPulse = 0; } - - NumberAnimation { - from: 0 - to: 1 - duration: 1000 - easing.type: Easing.Linear - } - - NumberAnimation { - from: 1 - to: 0 - duration: 1000 - easing.type: Easing.Linear + onTriggered: { + battery.criticalTick = (battery.criticalTick + 1) % 40; + battery.criticalPulse = 1 - Math.abs(20 - battery.criticalTick) / 20; } }