forked from Shinonome/dots-hyprland
disallow volume over 200%
This commit is contained in:
@@ -14,6 +14,7 @@ Singleton {
|
|||||||
property bool ready: Pipewire.defaultAudioSink?.ready ?? false
|
property bool ready: Pipewire.defaultAudioSink?.ready ?? false
|
||||||
property PwNode sink: Pipewire.defaultAudioSink
|
property PwNode sink: Pipewire.defaultAudioSink
|
||||||
property PwNode source: Pipewire.defaultAudioSource
|
property PwNode source: Pipewire.defaultAudioSource
|
||||||
|
readonly property real hardMaxValue: 2.00 // People keep joking about setting volume to 5172% so...
|
||||||
|
|
||||||
signal sinkProtectionTriggered(string reason);
|
signal sinkProtectionTriggered(string reason);
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ Singleton {
|
|||||||
if (newVolume - lastVolume > maxAllowedIncrease) {
|
if (newVolume - lastVolume > maxAllowedIncrease) {
|
||||||
sink.audio.volume = lastVolume;
|
sink.audio.volume = lastVolume;
|
||||||
root.sinkProtectionTriggered("Illegal increment");
|
root.sinkProtectionTriggered("Illegal increment");
|
||||||
} else if (newVolume > maxAllowed) {
|
} else if (newVolume > maxAllowed || newVolume > root.hardMaxValue) {
|
||||||
root.sinkProtectionTriggered("Exceeded max allowed");
|
root.sinkProtectionTriggered("Exceeded max allowed");
|
||||||
sink.audio.volume = Math.min(lastVolume, maxAllowed);
|
sink.audio.volume = Math.min(lastVolume, maxAllowed);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user