bash/for_orange/mpdsleep.sh

23 lines
480 B
Bash

#!/usr/bin/env bash
: "${1?How to use: $0 minutes}"
var_sec=$((${1} * 60 ))
# var_vol=$(mpc status %volume% | tr -d ' ,%')
var_vol=$(mpc volume | tr -d '[:punct:], ,[:alpha:]')
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