|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
#!/bin/bash |
|
|
|
|
# this is called by lightcommander |
|
|
|
|
logger $0 1=$1 2=$2 |
|
|
|
|
BEAMERIP=$(cat $(dirname "$0")"/beamerip.txt") |
|
|
|
|
function raisescreen() { |
|
|
|
@ -9,13 +10,30 @@ function lowerscreen() { |
|
|
|
|
echo "Rolling projection screen down" |
|
|
|
|
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down' |
|
|
|
|
} |
|
|
|
|
function beamerquery() { |
|
|
|
|
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')" |
|
|
|
|
if [ "$signalsource" = "" ] |
|
|
|
|
then |
|
|
|
|
signalsource="off" # I know bash can do this in 1 line, but this should still be readable |
|
|
|
|
fi |
|
|
|
|
echo "$signalsource" |
|
|
|
|
} |
|
|
|
|
function beameroff() { |
|
|
|
|
echo "Switching beamer off" |
|
|
|
|
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off |
|
|
|
|
} |
|
|
|
|
function beameron() { |
|
|
|
|
echo "Switching beamer on" |
|
|
|
|
currstatus="$(beamerquery)" |
|
|
|
|
echo "Switching beamer on (input was $currstatus)" |
|
|
|
|
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3101fe0660 #projector on |
|
|
|
|
if [ "$currstatus" = "off" ] |
|
|
|
|
then |
|
|
|
|
echo "Waiting for beamer to boot..." |
|
|
|
|
sleep 15 |
|
|
|
|
echo "... is now booted" |
|
|
|
|
return 0 |
|
|
|
|
fi |
|
|
|
|
return 1 |
|
|
|
|
} |
|
|
|
|
function dvi() { |
|
|
|
|
echo "Switching to dvi" |
|
|
|
@ -26,11 +44,8 @@ function hdmi1() { |
|
|
|
|
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3109f6071475 #switch to hdmi1 |
|
|
|
|
} |
|
|
|
|
function hdmi2() { |
|
|
|
|
receiveron |
|
|
|
|
echo "Switching to hdmi2" |
|
|
|
|
wget -qO/dev/null http://$projip/tgi/return.tgi?command=2a3109f6071576 #switch to hdmi2 |
|
|
|
|
sleep 4 |
|
|
|
|
receiverhdmi |
|
|
|
|
} |
|
|
|
|
function vga1() { |
|
|
|
|
echo "Switching to vga1" |
|
|
|
@ -70,6 +85,14 @@ function receivertuner() { |
|
|
|
|
echo "Switching receiver to tuner" |
|
|
|
|
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_TUNER"' |
|
|
|
|
} |
|
|
|
|
function receivervolumeup() { |
|
|
|
|
echo "Turning reciever volume up" |
|
|
|
|
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEUP"' |
|
|
|
|
} |
|
|
|
|
function receivervolumedown() { |
|
|
|
|
echo "Turning reciever volume down" |
|
|
|
|
ssh pi@doorbuzz '/usr/bin/irsend SEND_ONCE pioneer "KEY_VOLUMEDOWN"' |
|
|
|
|
} |
|
|
|
|
function usage() { |
|
|
|
|
echo "Usage: $0 (beamer|screen) (on|dvi|hdmi1|hdmi2|vga|off|down|up)" |
|
|
|
|
exit |
|
|
|
@ -82,13 +105,17 @@ case $1 in |
|
|
|
|
;; |
|
|
|
|
off) beameroff |
|
|
|
|
;; |
|
|
|
|
dvi) beameron; dvi |
|
|
|
|
dvi) dvi ; beameron && dvi |
|
|
|
|
;; |
|
|
|
|
hdmi1) beameron; hdmi1 |
|
|
|
|
hdmi1) hdmi1 ; beameron && hdmi1 |
|
|
|
|
;; |
|
|
|
|
hdmi2) beameron; hdmi2 |
|
|
|
|
hdmi2) hdmi2 |
|
|
|
|
( receiveron |
|
|
|
|
sleep 4 |
|
|
|
|
receiverhdmi ) & |
|
|
|
|
beameron && hdmi2 |
|
|
|
|
;; |
|
|
|
|
vga1) beameron; vga1 |
|
|
|
|
vga1) vga1 ; beameron && vga1 |
|
|
|
|
;; |
|
|
|
|
*) usage |
|
|
|
|
esac |
|
|
|
@ -118,6 +145,10 @@ case $1 in |
|
|
|
|
;; |
|
|
|
|
tuner) receivertuner |
|
|
|
|
;; |
|
|
|
|
"vol+") receivervolumeup |
|
|
|
|
;; |
|
|
|
|
"vol-") receivervolumedown |
|
|
|
|
;; |
|
|
|
|
*) usage |
|
|
|
|
esac |
|
|
|
|
;; |
|
|
|
@ -125,62 +156,3 @@ case $1 in |
|
|
|
|
usage |
|
|
|
|
;; |
|
|
|
|
esac 2>&1 | logger -t $0 |
|
|
|
|
exit |
|
|
|
|
if [ "$1" = "off" ] |
|
|
|
|
then |
|
|
|
|
( |
|
|
|
|
echo "called with parameter $1" |
|
|
|
|
projip="$BEAMERIP" |
|
|
|
|
if [ "$projip" = "" ] |
|
|
|
|
then |
|
|
|
|
echo "no projector IP found" |
|
|
|
|
arp -a |
|
|
|
|
raisescreen |
|
|
|
|
exit |
|
|
|
|
fi |
|
|
|
|
signalsource="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info' |awk -F'[<>]' '/<info>/{print substr($3,33,2)}')" |
|
|
|
|
if [ "$signalsource" = "00" ] || [ "$signalsource" = "15" ] || [ "$signalsource" = "" ] |
|
|
|
|
then |
|
|
|
|
raisescreen |
|
|
|
|
echo "wget http://$projip/tgi/return.tgi?command=2a3102fd0660 #projector off" |
|
|
|
|
wget -qO - 'http://'"$projip"'/tgi/return.tgi?command=2a3102fd0660' 2>&1 |
|
|
|
|
echo $? |
|
|
|
|
else |
|
|
|
|
echo "not disabling projector because source is at $signalsource" |
|
|
|
|
fi |
|
|
|
|
) | logger -t "$(basename $0) $$" |
|
|
|
|
exit |
|
|
|
|
fi & |
|
|
|
|
if [ "$1" = "off" ] |
|
|
|
|
then |
|
|
|
|
exit # because the if before is in background |
|
|
|
|
fi |
|
|
|
|
prevstatus="unknown" |
|
|
|
|
while true |
|
|
|
|
do |
|
|
|
|
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 |
|
|
|
|
# we only test if 01, because if off, it can also give no response |
|
|
|
|
# but seems to be bytes 32-33 more accurate |
|
|
|
|
statusbyte="$(wget -qO - 'http://'"$projip"'/tgi/return.tgi?query=info'|awk -F'[<>]' '/<info>/{print substr($3,31,2)}')" |
|
|
|
|
if [ "$statusbyte" = "01" ] |
|
|
|
|
then |
|
|
|
|
if [ "$prevstatus" != "on" ] |
|
|
|
|
then |
|
|
|
|
logger -t $(basename $0) "$$ Projector is on" |
|
|
|
|
ssh pi@doorbuzz 'doorbuzz/projectionscreen.sh down' |
|
|
|
|
prevstatus="on" |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
if [ "$prevstatus" != "off" ] |
|
|
|
|
then |
|
|
|
|
logger -t $(basename $0) "$$ Projector is off" |
|
|
|
|
prevstatus="off" |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
sleep 10 |
|
|
|
|
done |
|
|
|
|