bash/for_orange/mpdsleep.sh

23 lines
480 B
Bash
Raw Normal View History

2023-05-23 09:16:59 +00:00
#!/usr/bin/env bash
: "${1?How to use: $0 minutes}"
var_sec=$((${1} * 60 ))
2023-05-23 13:25:17 +00:00
# var_vol=$(mpc status %volume% | tr -d ' ,%')
var_vol=$(mpc volume | tr -d '[:punct:], ,[:alpha:]')
2023-05-23 09:16:59 +00:00
time_step=$(( "$var_sec" / 12 ))
vol_step=$(( "$var_vol" /12 ))
while (( "$var_sec" > 0 )); do
sleep "$time_step"
mpc volume -"$vol_step" > /dev/null
var_sec=$(( "$var_sec" - "$time_step" ))
if [[ $var_sec == 0 ]]
then
mpc stop > /dev/null
mpc volume "$var_vol" > /dev/null
fi
done
exit 0