add files
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# != 1 ]; then
|
||||
echo "Usage: ${0} up|down|mute"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
STEP=0.03 # Volume change step
|
||||
|
||||
get_vol() {
|
||||
playerctl -p mpd volume
|
||||
}
|
||||
|
||||
set_vol() {
|
||||
playerctl -p mpd volume $1
|
||||
}
|
||||
|
||||
current_vol=$(get_vol)
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
new_vol=$(echo "$current_vol + $STEP" | bc)
|
||||
[[ $(echo "$new_vol > 1.0" | bc) -eq 1 ]] && new_vol=1.0
|
||||
set_vol $new_vol
|
||||
;;
|
||||
down)
|
||||
new_vol=$(echo "$current_vol - $STEP" | bc)
|
||||
[[ $(echo "$new_vol < 0.0" | bc) -eq 1 ]] && new_vol=0.0
|
||||
set_vol $new_vol
|
||||
;;
|
||||
mute)
|
||||
if [[ "$current_vol" != "0.0" ]]; then
|
||||
set_vol 0.0
|
||||
else
|
||||
set_vol 0.5 # or store last volume
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} up|down|mute"
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user