mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-01 18:15:41 +00:00
AudioCard/Panel: add one-shot timer to prevent 100% volume on startup
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user