disallow volume over 200%

This commit is contained in:
end-4
2025-10-11 00:03:18 +02:00
parent 393d90d3f7
commit 01f8631663
+2 -1
View File
@@ -14,6 +14,7 @@ Singleton {
property bool ready: Pipewire.defaultAudioSink?.ready ?? false
property PwNode sink: Pipewire.defaultAudioSink
property PwNode source: Pipewire.defaultAudioSource
readonly property real hardMaxValue: 2.00 // People keep joking about setting volume to 5172% so...
signal sinkProtectionTriggered(string reason);
@@ -39,7 +40,7 @@ Singleton {
if (newVolume - lastVolume > maxAllowedIncrease) {
sink.audio.volume = lastVolume;
root.sinkProtectionTriggered("Illegal increment");
} else if (newVolume > maxAllowed) {
} else if (newVolume > maxAllowed || newVolume > root.hardMaxValue) {
root.sinkProtectionTriggered("Exceeded max allowed");
sink.audio.volume = Math.min(lastVolume, maxAllowed);
}