mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 06:28:27 -04:00
audio: revert wpctl workaround
related #2899
port 1.5
(cherry picked from commit 70ceee139b)
This commit is contained in:
@@ -847,7 +847,7 @@ EOFCONFIG
|
|||||||
|
|
||||||
const maxVol = root.sinkMaxVolume;
|
const maxVol = root.sinkMaxVolume;
|
||||||
const clampedVolume = Math.max(0, Math.min(maxVol, percentage));
|
const clampedVolume = Math.max(0, Math.min(maxVol, percentage));
|
||||||
Quickshell.execDetached(["wpctl", "set-volume", "-l", String(maxVol / 100), "@DEFAULT_AUDIO_SINK@", String(clampedVolume / 100)]);
|
root.sink.audio.volume = clampedVolume / 100;
|
||||||
return `Volume set to ${clampedVolume}%`;
|
return `Volume set to ${clampedVolume}%`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,14 +857,16 @@ EOFCONFIG
|
|||||||
}
|
}
|
||||||
|
|
||||||
function adjustDefaultSinkVolume(step, direction) {
|
function adjustDefaultSinkVolume(step, direction) {
|
||||||
|
const audio = root.sink.audio;
|
||||||
const maxVol = root.sinkMaxVolume;
|
const maxVol = root.sinkMaxVolume;
|
||||||
const stepValue = outputVolumeStep(step);
|
const stepValue = outputVolumeStep(step);
|
||||||
const currentVolume = Math.round(root.sink.audio.volume * 100);
|
const currentVolume = Math.round(audio.volume * 100);
|
||||||
const newVolume = Math.max(0, Math.min(maxVol, currentVolume + direction * stepValue));
|
const newVolume = Math.max(0, Math.min(maxVol, currentVolume + direction * stepValue));
|
||||||
const suffix = direction > 0 ? "+" : "-";
|
|
||||||
|
|
||||||
Quickshell.execDetached(["wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "0"]);
|
if (audio.muted)
|
||||||
Quickshell.execDetached(["wpctl", "set-volume", "-l", String(maxVol / 100), "@DEFAULT_AUDIO_SINK@", `${stepValue}%${suffix}`]);
|
audio.muted = false;
|
||||||
|
|
||||||
|
audio.volume = newVolume / 100;
|
||||||
return newVolume;
|
return newVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user