do some sound effects. aplay or speech synth. make peoplecounter play join and leave sounds in timely manner

master
Level2 Pidor 2017-01-19 21:59:15 +01:00
parent b02efa5861
commit e5e3bc99f6
5 changed files with 68 additions and 14 deletions

View File

@ -0,0 +1,20 @@
#!/bin/bash
(
if [ "$1" = "released" ]
then
sleep 2
aplay '/root/win/Windows XP Startup.wav'
#espeak -s 130 "Welcome to Level2." 2>/dev/null
fi
if [ "$1" = "pushed" ]
then
aplay '/root/win/Windows XP Critical Error.wav'
sleep 1
aplay '/root/win/Windows XP Critical Stop.wav'
#espeak -s 130 "Level2 is closing." 2>/dev/null
#espeak -s 120 -p 80 "Please wait, until all lights are off." 2>/dev/null
sleep 1
#espeak -s 120 -p 80 "I will tell you when I am finished." 2>/dev/null
aplay '/root/win/Windows XP Logoff.wav'
fi
) &

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ "$1" = "released" ]
then
:
# espeak -s 130 "Welcome to Level2." 2>/dev/null
fi
if [ "$1" = "pushed" ]
then
#espeak -s 130 "Thank you for waiting. I am done. Have a nice day." 2>/dev/null
aplay '/root/win/Windows XP Shutdown.wav'
fi

View File

@ -10,7 +10,8 @@ else
fi fi
STATSFILE="/run/peoplecounter$DEV" STATSFILE="/run/peoplecounter$DEV"
SAMPLES=20 # how many records to keep in file SAMPLES=20 # how many records to keep in file
INTERVAL=10 # how long to wait between polls INTERVAL=0 # how long to wait between polls
INTERVALSKIP=20 # poll with INTERVAL but only consider every INTERVALSKIP's for SAMPLES
MAXFILE="/var/cache/peoplecountermax$DEV" MAXFILE="/var/cache/peoplecountermax$DEV"
PRESENCY="/run/presency$DEV" # value shown on website PRESENCY="/run/presency$DEV" # value shown on website
# /run/peoplecounter lists all recent reads, newest at end # /run/peoplecounter lists all recent reads, newest at end
@ -52,6 +53,7 @@ function addcount() {
} }
PEOPLECOUNTERIP=$(cat $(dirname "$0")"/peoplecounterip.txt") PEOPLECOUNTERIP=$(cat $(dirname "$0")"/peoplecounterip.txt")
state="online" state="online"
rtoldp=0
while true while true
do do
# scrape new value # scrape new value
@ -59,10 +61,17 @@ do
wget -qO - "http://$PEOPLECOUNTERIP/output.cgi?t=$(date +%s)" | wget -qO - "http://$PEOPLECOUNTERIP/output.cgi?t=$(date +%s)" |
sed 's/.*Occupancy://'| sed 's/.*Occupancy://'|
awk '{print $2}')" awk '{print $2}')"
# echo "p=$p" # debug
if [ "$p" != "" ] # oh we got something if [ "$p" != "" ] # oh we got something
then then
oldp="$(getlastpeople)" oldp="$(getlastpeople)"
skipcounter=$((skipcounter+1))
if [ $skipcounter -gt $INTERVALSKIP ]
then
# echo "skipcounter expired. updating" # debug
skipcounter=0
addcount "$p" addcount "$p"
# if max then call this:
if [ "$p" != "$oldp" ] if [ "$p" != "$oldp" ]
then then
logger $(basename $0) changed from $oldp to $p people logger $(basename $0) changed from $oldp to $p people
@ -75,6 +84,20 @@ do
chmod a+rw "$MAXFILE" chmod a+rw "$MAXFILE"
fi fi
fi fi
fi
if [ $p -gt $rtoldp ]
then
# echo "p($p) -gt rtoldp($rtoldp)" # debug
aplay '/root/win/Windows XP Logon Sound.wav'
fi
if [ $p -lt $rtoldp ]
then
# echo "p($p) -lt rtoldp($rtoldp)" # debug
aplay '/root/win/Windows XP Logoff Sound.wav'
fi
# echo "rtoldp=$p" # debug
rtoldp=$p
oldaverage="$(cat "$PRESENCY")" oldaverage="$(cat "$PRESENCY")"
newaverage=$(getaveragepeople) newaverage=$(getaveragepeople)
#logger $(basename $0) averages o=$oldaverage n=$newaverage #logger $(basename $0) averages o=$oldaverage n=$newaverage

View File

@ -42,7 +42,7 @@ doorlockbutton="$(cat /run/doorlockbutton)"
nai=$(stat -c "%Y" /run/spacestatus) # get mtime as status change time nai=$(stat -c "%Y" /run/spacestatus) # get mtime as status change time
if [ "$status" = "open" ] if [ "$status" = "open" ]
then then
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set /usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":true,"lastchange":'"$nai"'}}' https://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?" #logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi fi
for plugin in $(ls "$0".d) for plugin in $(ls "$0".d)
@ -60,7 +60,7 @@ then
# problem: if closing state but not actually shuting door for a longer time, the status in spaceapi # problem: if closing state but not actually shuting door for a longer time, the status in spaceapi
# will be the time of closing but not that of actually shutting the door # will be the time of closing but not that of actually shutting the door
# but the status will only be updated once the door is shut # but the status will only be updated once the door is shut
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' http://spaceapi.syn2cat.lu/sensor/set /usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"state":{"open":false,"lastchange":'"$nai"'}}' https://spaceapi.syn2cat.lu/sensor/set
#logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?" #logger -t $(basename $0) "$$ sending status $status to spacapi ret=$?"
fi fi
@ -74,5 +74,5 @@ if [ "$status" = "closed" ]
then then
presency=0 presency=0
fi fi
/usr/bin/curl --max-time 1 --silent --insecure --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' http://spaceapi.syn2cat.lu/sensor/set /usr/bin/curl --max-time 1 --silent --data key="$spaceapikey" --data-urlencode sensors='{"sensors":{"people_now_present":[{"value":'"$presency"'}]}}' https://spaceapi.syn2cat.lu/sensor/set
V V

View File

@ -91,8 +91,8 @@
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="optical" >Optical (BluRay) 5.1</a></p> <p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="optical" >Optical (BluRay) 5.1</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="cd" >CD (white laptop)r</a></p> <p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="cd" >CD (white laptop)r</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="tuner" >Tuner</a></p> <p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="tuner" >Tuner</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol-" >Vol-</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol+" >Vol+</a></p> <p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol+" >Vol+</a></p>
<p><a class="btn btn-success btn-lg btn-block" data-area="receiver" data-status="vol-" >Vol-</a></p>
<p><a class="col-md-3 btn btn-danger btn-lg btn-block" data-area="receiver" data-status="off" >Off</a></p> <p><a class="col-md-3 btn btn-danger btn-lg btn-block" data-area="receiver" data-status="off" >Off</a></p>
</div> </div>
</div> </div>