2015-07-05 02:41:09 +02:00
|
|
|
#!/bin/bash
|
2016-01-17 19:45:44 +01:00
|
|
|
BEAMERIP=$(cat $(dirname "$0")"/beamerip.txt")
|
|
|
|
function raisescreen() {
|
|
|
|
echo "Rolling projection screen up"
|
|
|
|
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh up'
|
|
|
|
}
|
|
|
|
function pingall() {
|
|
|
|
i=1
|
|
|
|
while [ $i -lt 255 ]
|
|
|
|
do
|
|
|
|
ping -c 1 10.2.113.$i -q >/dev/null &
|
|
|
|
i=$((i+1))
|
|
|
|
done
|
|
|
|
wait
|
|
|
|
}
|
2015-07-22 00:48:43 +02:00
|
|
|
if [ "$1" = "off" ]
|
|
|
|
then
|
2015-07-24 21:10:06 +02:00
|
|
|
(
|
2015-08-03 20:12:22 +02:00
|
|
|
echo "called with parameter $1"
|
2016-01-17 19:45:44 +01:00
|
|
|
projip="$BEAMERIP"
|
2015-08-03 20:12:22 +02:00
|
|
|
if [ "$projip" = "" ]
|
|
|
|
then
|
|
|
|
echo "no projector IP found"
|
2016-01-17 19:45:44 +01:00
|
|
|
arp -a
|
|
|
|
raisescreen
|
2015-08-03 20:12:22 +02:00
|
|
|
exit
|
|
|
|
fi
|
2015-07-24 21:10:06 +02:00
|
|
|
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')"
|
2016-06-27 21:50:45 +02:00
|
|
|
#if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ]
|
2016-11-17 19:27:24 +01:00
|
|
|
if [ "$signalsource" = "00" ] ||
|
|
|
|
[ "$signalsource" = "02" ] ||
|
|
|
|
[ "$signalsource" = "" ] ||
|
|
|
|
( [ "$signalsource" = "15" ] &&
|
|
|
|
[ "$(cat /var/run/caststatus)" = "Backdrop" ] )
|
|
|
|
then # port 15 is hdmi1 (chromecast)
|
2016-01-17 19:45:44 +01:00
|
|
|
raisescreen
|
2015-08-03 20:12:22 +02:00
|
|
|
echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off"
|
2015-07-24 21:10:06 +02:00
|
|
|
wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1
|
|
|
|
echo $?
|
|
|
|
else
|
2015-08-03 20:12:22 +02:00
|
|
|
echo "not disabling projector because source is at $signalsource"
|
2015-07-24 21:10:06 +02:00
|
|
|
fi
|
|
|
|
) | logger -t "$(basename $0) $$"
|
2015-07-22 00:48:43 +02:00
|
|
|
exit
|
2016-01-17 19:45:44 +01:00
|
|
|
fi &
|
|
|
|
if [ "$1" = "off" ]
|
|
|
|
then
|
|
|
|
exit # because the if before is in background
|
2015-07-22 00:48:43 +02:00
|
|
|
fi
|
2015-07-05 02:41:09 +02:00
|
|
|
prevstatus="unknown"
|
|
|
|
while true
|
|
|
|
do
|
2016-01-17 19:45:44 +01:00
|
|
|
if [ $(date +%H) -eq 23 ]
|
|
|
|
then
|
|
|
|
pingall
|
|
|
|
fi
|
|
|
|
projip="$BEAMERIP"
|
|
|
|
# from the acer webpage we read that bytes 30-31 contain 00 if power off and 01 if power on
|
2015-07-05 02:41:09 +02:00
|
|
|
# we only test if 01, because if off, it can also give no response
|
|
|
|
# but seems to be bytes 32-33 more accurate
|
2015-07-22 00:48:43 +02:00
|
|
|
statusbyte="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info'|awk -F'[<>]' '/<info>/{print substr($3,31,2)}')"
|
2015-07-05 02:41:09 +02:00
|
|
|
if [ "$statusbyte" = "01" ]
|
|
|
|
then
|
|
|
|
if [ "$prevstatus" != "on" ]
|
|
|
|
then
|
|
|
|
logger -t $(basename $0) "$$ Projector is on"
|
2015-07-22 00:48:43 +02:00
|
|
|
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down'
|
2015-07-05 02:41:09 +02:00
|
|
|
prevstatus="on"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$prevstatus" != "off" ]
|
|
|
|
then
|
|
|
|
logger -t $(basename $0) "$$ Projector is off"
|
|
|
|
prevstatus="off"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
sleep 10
|
|
|
|
done
|