2020-12-13 22:15:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
export ROOT=`dirname "$DIR"`
|
|
|
|
export SOUNDS=$ROOT/sounds
|
|
|
|
|
|
|
|
export PLAYER=mplayer
|
|
|
|
export SPEAK=espeak-ng
|
|
|
|
|
|
|
|
function info() {
|
|
|
|
echo "[INFO]" $@
|
|
|
|
}
|
|
|
|
|
|
|
|
function play() {
|
|
|
|
$PLAYER $@ > /dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2020-12-14 13:14:43 +00:00
|
|
|
function pa-volume() {
|
|
|
|
amixer cset numid=3,iface=MIXER,name='Line Out Playback Volume' $1 > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-volume-normal() {
|
2020-12-14 16:23:50 +00:00
|
|
|
info "Volume set to Normal"
|
2020-12-14 13:14:43 +00:00
|
|
|
pa-volume 15
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-volume-loud() {
|
2020-12-14 16:23:50 +00:00
|
|
|
info "Volume set to HIGH!"
|
2020-12-14 13:14:43 +00:00
|
|
|
pa-volume 25
|
|
|
|
}
|
|
|
|
|
2020-12-17 19:08:59 +00:00
|
|
|
function pa-volume-loud-if-inactive() {
|
|
|
|
LAST_ACTIVE=`human-activity-ago`
|
|
|
|
if [[ $LAST_ACTIVE > 200 ]]; then
|
|
|
|
info "Human is inactive. Last activity: $LAST_ACTIVE seconds ago."
|
|
|
|
pa-volume-loud
|
|
|
|
else
|
|
|
|
info "Human is active. Setting only normal volume."
|
|
|
|
pa-volume-normal
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-14 13:14:43 +00:00
|
|
|
function pa-volume-quiet() {
|
2020-12-14 16:23:50 +00:00
|
|
|
info "Volume set to low"
|
2020-12-14 13:14:43 +00:00
|
|
|
pa-volume 8
|
|
|
|
}
|
|
|
|
|
2020-12-13 22:15:26 +00:00
|
|
|
function pa-preheat() {
|
|
|
|
info "PA Preheating"
|
|
|
|
pa-power off
|
2020-12-14 13:14:43 +00:00
|
|
|
pa-volume-normal
|
2020-12-13 22:15:26 +00:00
|
|
|
play $SOUNDS/announcement_4-tone_up_quickest.ogg
|
|
|
|
pa-power on
|
|
|
|
info "PA Ready"
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-shutdown() {
|
|
|
|
info "PA Shutdown"
|
|
|
|
pa-power off
|
2020-12-14 13:14:43 +00:00
|
|
|
pa-volume-normal
|
2020-12-17 19:08:59 +00:00
|
|
|
killall $PLAYER
|
2020-12-13 22:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function pa-announcement() {
|
|
|
|
info " DING DONG "
|
|
|
|
play $SOUNDS/announcement_4-tone_up_smooth.ogg
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-announcement-quick() {
|
|
|
|
info " Ding Dong "
|
|
|
|
play $SOUNDS/announcement_4-tone_up_smooth_quick.ogg
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-announcement-quickest() {
|
|
|
|
info " ding-dong "
|
|
|
|
play $SOUNDS/announcement_4-tone_up_quickest.ogg
|
|
|
|
}
|
|
|
|
|
2020-12-14 16:23:50 +00:00
|
|
|
function pa-alarm-start() {
|
|
|
|
info "Alarm started"
|
|
|
|
play -loop 0 $SOUNDS/alarm_simple.ogg &
|
|
|
|
}
|
|
|
|
|
|
|
|
function pa-alarm-stop() {
|
|
|
|
info "Alarm stopped"
|
|
|
|
killall $PLAYER
|
|
|
|
}
|
|
|
|
|
2020-12-13 22:15:26 +00:00
|
|
|
function pa-say() {
|
|
|
|
info "Say: $@"
|
|
|
|
$SPEAK "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
|