rewrited from python
This commit is contained in:
parent
0958bcd274
commit
2ddab7cc39
32
for_orange/mpdalarm.sh
Normal file
32
for_orange/mpdalarm.sh
Normal 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
21
for_orange/mpdsleep.sh
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user