forked from Shinonome/dots-hyprland
in freaking 2 lines
This commit is contained in:
@@ -27,18 +27,9 @@ function trimTrackTitle(title) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function adjustVolume(direction) {
|
function adjustVolume(direction) {
|
||||||
const step = 0.03;
|
const step = 0.1; // We use a larger step because this is player instance volume, not global
|
||||||
execAsync(['playerctl', 'volume'])
|
const mpris = Mpris.getPlayer('');
|
||||||
.then((output) => {
|
mpris.volume += (direction === 'up') ? step : -step
|
||||||
let currentVolume = parseFloat(output.trim());
|
|
||||||
let newVolume = direction === 'up' ? currentVolume + step : currentVolume - step;
|
|
||||||
|
|
||||||
if (newVolume > 1.0) newVolume = 1.0;
|
|
||||||
if (newVolume < 0.0) newVolume = 0.0;
|
|
||||||
|
|
||||||
execAsync(['playerctl', 'volume', newVolume.toFixed(2)]).catch(print);
|
|
||||||
})
|
|
||||||
.catch(print);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
change=$1
|
|
||||||
|
|
||||||
current_volume=$(playerctl volume)
|
|
||||||
|
|
||||||
new_volume=$(echo "$current_volume + $change" | bc)
|
|
||||||
|
|
||||||
if (( $(echo "$new_volume > 1.0" | bc -l) )); then
|
|
||||||
new_volume=1.0
|
|
||||||
elif (( $(echo "$new_volume < 0.0" | bc -l) )); then
|
|
||||||
new_volume=0.0
|
|
||||||
fi
|
|
||||||
|
|
||||||
playerctl volume "$new_volume"
|
|
||||||
Reference in New Issue
Block a user