script to detect if beamer is on or off

currently logs to syslog
could make the screen go up/down automatically
e.g. down on beamer on, up on hackerspace closed
master
Georges 2015-07-05 02:41:09 +02:00
parent 4dc5da4a26
commit 7643aa2a64
1 changed files with 25 additions and 0 deletions

25
scripts/beamerdetect.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
prevstatus="unknown"
while true
do
projip=$(arp -an|awk -F'[()]' '/00:50:41:79:d1:34/{print $2}')
# from the acer webpage we read that bytes 30-31 contain 00 if poer 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://10.2.113.104/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"
prevstatus="on"
fi
else
if [ "$prevstatus" != "off" ]
then
logger -t $(basename $0) "$$ Projector is off"
prevstatus="off"
fi
fi
sleep 10
done