Created
April 24, 2013 16:30
-
-
Save urcadox/5453502 to your computer and use it in GitHub Desktop.
See blog post: http://blog.alexandre.berthaud.me/posts/2013-04-25-using-a-raspberry-pi-as-an-alarm-clock-with-mpd.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SLEEP=`echo "$1*3600" | bc` | |
echo "Alarm triggered in $1 hours" | |
sleep $SLEEP > /dev/null | |
echo "Starting playing" | |
mpc volume 50 > /dev/null | |
mpc play > /dev/null | |
mpcfade.sh 50 65 0 | |
mpcfade.sh 65 75 1 | |
echo "Turning on TV and switching input to me" | |
(echo "as" | cec-client -s -d 5) & | |
mpcfade.sh 75 82 2 | |
mpcfade.sh 82 90 4 | |
echo "Full volume, have a good day!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VOL=$1 | |
TO=$2 | |
SLEEP=$3 | |
echo "Fading from $VOL% to $TO% (step: $SLEEP second(s))" | |
mpc volume $VOL > /dev/null | |
if [ $VOL -lt $TO ] | |
then | |
while [ $VOL -lt $TO ] | |
do | |
sleep $SLEEP > /dev/null | |
VOL=$[$VOL+1] | |
mpc volume $VOL > /dev/null | |
done | |
else | |
while [ $VOL -gt $TO ] | |
do | |
sleep $SLEEP > /dev/null | |
VOL=$[$VOL-1] | |
mpc volume $VOL > /dev/null | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment