Advertisement
rabreu

alarmpi.sh

Feb 2nd, 2014
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.74 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Alarm script for working along with crond on a Raspberry Pi board plugged in a HDTV.
  4. # Deps: cec-client, mpd, mpc, tty-clock
  5. #
  6. # Rodrigo Abreu <rodrigo@ilostmyself.org>
  7.  
  8. TERM=xterm
  9. export TERM
  10.  
  11. TIME=75                                         # Alarm runtime period (in minutes)
  12.  
  13. echo "on 0.0.0.0" | cec-client -s > /dev/null   # Turns on the TV
  14. echo -ne '\033[9;0]' > /dev/tty1                # Unblanks screen
  15. setterm -blank 0 -powerdown 0 > /dev/tty1       # Prevents the TV from blanking during alarm runtime
  16. mpc clear > /dev/null                           # Clears MPD's queue
  17. mpc load alarm > /dev/null                      # Loads alarm playlist to MPD's queue
  18. mpc repeat on > /dev/null                       # Enables repeat
  19. mpc disable "Behringer UCA202" > /dev/null      # It's recommended to disable any other audio output
  20. mpc enable HDMI > /dev/null                     # Enables HDMI audio output
  21. mpc play > /dev/null                            # Play
  22. tty-clock -S -c -t -d 3 > /dev/tty1 &           # Runs tty-clock (a ncurses clock) to be shown on the HDTV screen
  23. sleep $[$TIME*60]                               # Sleeping beauty
  24. TTY_CLOCK_PID=$(pidof tty-clock)                # Gets tty-clock PID
  25. mpc stop > /dev/null                            # Stops MPD after sleeping beauty
  26. mpc disable HDMI > /dev/null                    # Disables HDMI audio output
  27. mpc enable "Behringer UCA202" > /dev/null       # Enables any other audio output
  28. kill -9 $TTY_CLOCK_PID > /dev/null              # Kills tty-clock
  29. clear > /dev/tty1                               # Clears and blanks the screen after a few seconds
  30. # 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