From bd0ddda7c67ce1f90cd8a4a7fd4475a39db1ae75 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Tue, 11 Nov 2025 15:16:32 +0100 Subject: [PATCH] AudioCard/Panel: add one-shot timer to prevent 100% volume on startup --- Modules/Panels/Audio/AudioPanel.qml | 38 +++++++++++++++---- .../Panels/ControlCenter/Cards/AudioCard.qml | 38 +++++++++++++++---- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/Modules/Panels/Audio/AudioPanel.qml b/Modules/Panels/Audio/AudioPanel.qml index 6d857791..a8e47493 100644 --- a/Modules/Panels/Audio/AudioPanel.qml +++ b/Modules/Panels/Audio/AudioPanel.qml @@ -39,15 +39,23 @@ SmartPanel { } } - // Timer to debounce volume changes + // Debounce timers to avoid forcing PipeWire volume on startup Timer { + id: outputDebounceTimer interval: 100 - running: true - repeat: true + repeat: false onTriggered: { if (Math.abs(localOutputVolume - AudioService.volume) >= 0.01) { AudioService.setVolume(localOutputVolume) } + } + } + + Timer { + id: inputDebounceTimer + interval: 100 + repeat: false + onTriggered: { if (Math.abs(localInputVolume - AudioService.inputVolume) >= 0.01) { AudioService.setInputVolume(localInputVolume) } @@ -164,8 +172,16 @@ SmartPanel { value: localOutputVolume stepSize: 0.01 heightRatio: 0.5 - onMoved: value => localOutputVolume = value - onPressedChanged: (pressed, value) => localOutputVolumeChanging = pressed + onMoved: value => { + localOutputVolume = value + outputDebounceTimer.restart() + } + onPressedChanged: (pressed, value) => { + localOutputVolumeChanging = pressed + if (!pressed) { + outputDebounceTimer.restart() + } + } text: Math.round(localOutputVolume * 100) + "%" Layout.bottomMargin: Style.marginM } @@ -221,8 +237,16 @@ SmartPanel { value: localInputVolume stepSize: 0.01 heightRatio: 0.5 - onMoved: value => localInputVolume = value - onPressedChanged: (pressed, value) => localInputVolumeChanging = pressed + onMoved: value => { + localInputVolume = value + inputDebounceTimer.restart() + } + onPressedChanged: (pressed, value) => { + localInputVolumeChanging = pressed + if (!pressed) { + inputDebounceTimer.restart() + } + } text: Math.round(localInputVolume * 100) + "%" Layout.bottomMargin: Style.marginM } diff --git a/Modules/Panels/ControlCenter/Cards/AudioCard.qml b/Modules/Panels/ControlCenter/Cards/AudioCard.qml index 47c35711..dfd90eaf 100644 --- a/Modules/Panels/ControlCenter/Cards/AudioCard.qml +++ b/Modules/Panels/ControlCenter/Cards/AudioCard.qml @@ -15,15 +15,23 @@ NBox { property real localInputVolume: AudioService.inputVolume || 0 property bool localInputVolumeChanging: false - // Timer to debounce volume changes + // Debounce timers to avoid spamming PipeWire on startup/idle Timer { + id: outputDebounceTimer interval: 100 - running: true - repeat: true + repeat: false onTriggered: { if (Math.abs(localOutputVolume - AudioService.volume) >= 0.01) { AudioService.setVolume(localOutputVolume) } + } + } + + Timer { + id: inputDebounceTimer + interval: 100 + repeat: false + onTriggered: { if (Math.abs(localInputVolume - AudioService.inputVolume) >= 0.01) { AudioService.setInputVolume(localInputVolume) } @@ -99,8 +107,16 @@ NBox { value: localOutputVolume stepSize: 0.01 heightRatio: 0.5 - onMoved: localOutputVolume = value - onPressedChanged: localOutputVolumeChanging = pressed + onMoved: { + localOutputVolume = value + outputDebounceTimer.restart() + } + onPressedChanged: { + localOutputVolumeChanging = pressed + if (!pressed) { + outputDebounceTimer.restart() + } + } tooltipText: `${Math.round(localOutputVolume * 100)}%` tooltipDirection: "bottom" } @@ -147,8 +163,16 @@ NBox { value: localInputVolume stepSize: 0.01 heightRatio: 0.5 - onMoved: localInputVolume = value - onPressedChanged: localInputVolumeChanging = pressed + onMoved: { + localInputVolume = value + inputDebounceTimer.restart() + } + onPressedChanged: { + localInputVolumeChanging = pressed + if (!pressed) { + inputDebounceTimer.restart() + } + } tooltipText: `${Math.round(localInputVolume * 100)}%` tooltipDirection: "bottom" }