Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Alarm script for working along with crond on a Raspberry Pi board plugged in a HDTV.
- # Deps: cec-client, mpd, mpc, tty-clock
- #
- # Rodrigo Abreu <rodrigo@ilostmyself.org>
- TERM=xterm
- export TERM
- TIME=75 # Alarm runtime period (in minutes)
- echo "on 0.0.0.0" | cec-client -s > /dev/null # Turns on the TV
- echo -ne '\033[9;0]' > /dev/tty1 # Unblanks screen
- setterm -blank 0 -powerdown 0 > /dev/tty1 # Prevents the TV from blanking during alarm runtime
- mpc clear > /dev/null # Clears MPD's queue
- mpc load alarm > /dev/null # Loads alarm playlist to MPD's queue
- mpc repeat on > /dev/null # Enables repeat
- mpc disable "Behringer UCA202" > /dev/null # It's recommended to disable any other audio output
- mpc enable HDMI > /dev/null # Enables HDMI audio output
- mpc play > /dev/null # Play
- tty-clock -S -c -t -d 3 > /dev/tty1 & # Runs tty-clock (a ncurses clock) to be shown on the HDTV screen
- sleep $[$TIME*60] # Sleeping beauty
- TTY_CLOCK_PID=$(pidof tty-clock) # Gets tty-clock PID
- mpc stop > /dev/null # Stops MPD after sleeping beauty
- mpc disable HDMI > /dev/null # Disables HDMI audio output
- mpc enable "Behringer UCA202" > /dev/null # Enables any other audio output
- kill -9 $TTY_CLOCK_PID > /dev/null # Kills tty-clock
- clear > /dev/tty1 # Clears and blanks the screen after a few seconds
- # echo "standby 0" | cec-client -s > /dev/null # Turns off the TV. See if this line works isolatedly before to uncomment.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement