rewrited from python

This commit is contained in:
паша душный 2023-05-23 12:16:59 +03:00
parent 0958bcd274
commit 2ddab7cc39
2 changed files with 53 additions and 0 deletions

32
for_orange/mpdalarm.sh Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
: "${1?How to use: $0 hh mm}"
var_date=$1:$2
echo "(T)omorrow or (t)oday? "
read -r var_day
case "$var_day" in
"T")
var_time=$(date --date="${var_date} tomorrow" +%s)
;;
"t")
var_time=$(date --date="${var_date}" +%s)
;;
esac
while (( "$var_time" > $(date +%s) )); do
sleep 30
done
mpc volume 20 > /dev/null
echo "ALARM!"
mpc play > /dev/null
for i in 10 20 30 30 20 10 ; do
sleep ${i}
mpc volume +10 > /dev/null
done
exit 0

21
for_orange/mpdsleep.sh Normal file
View File

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