You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
1.6 KiB

  1. #!/bin/bash
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  3. export ROOT=`dirname "$DIR"`
  4. export SOUNDS=$ROOT/sounds
  5. export PLAYER=mplayer
  6. export SPEAK=espeak-ng
  7. function info() {
  8. echo "[INFO]" $@
  9. }
  10. function play() {
  11. $PLAYER $@ > /dev/null 2>&1
  12. }
  13. function pa-volume() {
  14. amixer cset numid=3,iface=MIXER,name='Line Out Playback Volume' $1 > /dev/null
  15. }
  16. function pa-volume-normal() {
  17. info "Volume set to Normal"
  18. pa-volume 15
  19. }
  20. function pa-volume-loud() {
  21. info "Volume set to HIGH!"
  22. pa-volume 25
  23. }
  24. function pa-volume-loud-if-inactive() {
  25. LAST_ACTIVE=`human-activity-ago`
  26. if [[ $LAST_ACTIVE > 200 ]]; then
  27. info "Human is inactive. Last activity: $LAST_ACTIVE seconds ago."
  28. pa-volume-loud
  29. else
  30. info "Human is active. Setting only normal volume."
  31. pa-volume-normal
  32. fi
  33. }
  34. function pa-volume-quiet() {
  35. info "Volume set to low"
  36. pa-volume 8
  37. }
  38. function pa-preheat() {
  39. info "PA Preheating"
  40. pa-power off
  41. pa-volume-normal
  42. play $SOUNDS/announcement_4-tone_up_quickest.ogg
  43. pa-power on
  44. info "PA Ready"
  45. }
  46. function pa-shutdown() {
  47. info "PA Shutdown"
  48. pa-power off
  49. pa-volume-normal
  50. killall $PLAYER
  51. }
  52. function pa-announcement() {
  53. info " DING DONG "
  54. play $SOUNDS/announcement_4-tone_up_smooth.ogg
  55. }
  56. function pa-announcement-quick() {
  57. info " Ding Dong "
  58. play $SOUNDS/announcement_4-tone_up_smooth_quick.ogg
  59. }
  60. function pa-announcement-quickest() {
  61. info " ding-dong "
  62. play $SOUNDS/announcement_4-tone_up_quickest.ogg
  63. }
  64. function pa-alarm-start() {
  65. info "Alarm started"
  66. play -loop 0 $SOUNDS/alarm_simple.ogg &
  67. }
  68. function pa-alarm-stop() {
  69. info "Alarm stopped"
  70. killall $PLAYER
  71. }
  72. function pa-say() {
  73. info "Say: $@"
  74. $SPEAK "$@"
  75. }