diff options
Diffstat (limited to 'god')
-rwxr-xr-x | god/Reaktor/index | 39 | ||||
-rwxr-xr-x | god/Reaktor/lib/listener.py | 50 | ||||
-rwxr-xr-x | god/licht | 115 | ||||
-rw-r--r-- | god/overlord/announce.mp3 | bin | 0 -> 71496 bytes | |||
-rwxr-xr-x | god/overlord/index | 27 |
5 files changed, 222 insertions, 9 deletions
diff --git a/god/Reaktor/index b/god/Reaktor/index new file mode 100755 index 00000000..a7840bb2 --- /dev/null +++ b/god/Reaktor/index @@ -0,0 +1,39 @@ +#! /bin/sh +# +# //god/Reaktor - listen to UDP events and forward them to IRC +# +# export host passwd printto to configure jsb-udp +# +set -euf +cd $(readlink -f $(dirname $0)) + +listener=$(readlink -f lib/listener.py) + +jsb_version=0.7.1.2 +distdir=jsb-$jsb_version.tar.gz + +host=${host-91.206.142.247} +passwd=${passwd-h4x0r} +printto=${printto-#tincspasm} + +if ! test -x tmp/jsb-$jsb_version; then + mkdir -p tmp + cd tmp + curl -f http://jsonbot.googlecode.com/files/jsb-$jsb_version.tar.gz | tar zx + cd jsb-$jsb_version + bin/jsb-udp -s </dev/null + cd ../.. +fi +cd tmp/jsb-$jsb_version + +# TODO only if it is not already configured properly +cache="`cat config/udp-send`" +echo "$cache" | +sed ' + s/^host *=.*/host="'$host'"/ + s/^passwd *=.*/passwd="'$passwd'"/ + s/^printto *=.*/printto="'$printto'"/ +' > config/udp-send + +# TODO output modules: stderr, jsb-udp, remount-ro, ... +PYTHONUNBUFFERED=y $listener | tee /dev/stderr | bin/jsb-udp diff --git a/god/Reaktor/lib/listener.py b/god/Reaktor/lib/listener.py new file mode 100755 index 00000000..9708d9bc --- /dev/null +++ b/god/Reaktor/lib/listener.py @@ -0,0 +1,50 @@ +#! /usr/bin/env python2 +# coding=UTF-8 + +location = 'shackspace' +host = '0.0.0.0' +port = 2342 + +map = { + 'shackspace': { + 'device': { + 0: 'Licht0, Zickenzone; Fenster', + 1: 'Licht1, Sofaecke; Fenster', + 2: 'Licht2, Zickenzone; Ghetto', + 3: 'Licht3, Sofaecke; Ghetto', + 4: 'Licht4, Richtung Getränkelager', + 5: 'Licht5, Porschekonsole', + 6: 'Licht6, Tomatenecke', + 7: 'Licht7, Ghetto', + 10: 'Hauptschalter' + }, + 'state': { + 0: 'aus', + 1: 'an', + 2: 'aus in T-10s' + }, + '->': 'ist' + } +} + +import socket +from string import join +from struct import unpack + +# create udp socket +mysocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +# allow send/recieve from broacast address +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1) + +# allow the socket to be re-used +mysocket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) +mysocket.bind((host, port)) + +map = map[location] + +while True: + did, sid = unpack('BB', mysocket.recv(2)) + device, state = map['device'][did], map['state'][sid] + arrow = map['->'] + print join([device, arrow, state], ' ') @@ -1,20 +1,117 @@ #!/bin/bash -case "$1" in - (--help) echo "Toggle the lights";; - (*) - LAMPE=`echo $1 | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc` - TOGGLE=`echo $2 | sed -n '/^[0-1]/p'` +# +#SYNOPSIS +# //god/licht [options] [0/1] +#OPTIONS +# all - toggles all lights +# links - toggles all lights on the left hand side while looking towards the Auditorium +# rechts - toggles all lights on the right hand side while looking towards the Auditorium +# kuschel - toggles the lights in the pwnie corner +# software - toggles the software corner +# tische - toggles the lights on the window side of the long table +# porsche - toggles the lights on the window side where the porsche cockpit is +# ghetto - toggles the lights in the hallway +# 0-7 - toggles individual lights + +toggle() { + LAMPE=`echo "$1" | sed -n '/^[1-2]*[0-9]*[0-9]$/p' | xargs echo "obase=16;" | bc` + TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` if ! [ "$LAMPE" -a "$TOGGLE" ];then echo "you are made of stupid" exit 1 fi - STRING="\xA5\x5A\x$LAMPE\x$TOGGLE" + STRING="\\xA5\\x5A\\x$LAMPE\\x$TOGGLE" if [ $# != 2 ] then - echo -ne "Usage: licht <lampe> <0/1>" + echo "Usage: licht <lampe> <0/1>" else echo "Toggle light $LAMPE ($TOGGLE)" - echo -ne "$STRING" | nc -u -w1 licht.shack 1337 + printf "$STRING" | nc -u -w1 licht.shack 1337 fi - ;; +} + +toggle_all() { + for i in `seq 0 7` + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +kuschel(){ + for i in 0 2 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +software(){ + for i in 1 3 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +tische(){ + for i in 4 6 + do + printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + done + wait +} + +ghetto(){ + printf "\\xA5\\x5A\\x7\\x$TOGGLE" | nc -u -w1 licht.shack 1337 +} + +porsche(){ + printf "\\xA5\\x5A\\x5\\x$TOGGLE" | nc -u -w1 licht.shack 1337 +} + +case "$1" in + --help) + echo "Toggle the lights" + echo "Usage: lich <lampe> <0/1>" + ;; + all) + TOGGLE=$2 + toggle_all + ;; + kuschel) + TOGGLE=$2 + kuschel + ;; + software) + TOGGLE=$2 + software + ;; + links) + TOGGLE=$2 + kuschel + software + ;; + rechts) + TOGGLE=$2 + tische + porsche + ghetto + ;; + tische) + TOGGLE=$2 + tische + ;; + porsche) + TOGGLE=$2 + porsche + ;; + ghetto) + TOGGLE=$2 + ghetto + ;; + *) + toggle "$@" + ;; esac + diff --git a/god/overlord/announce.mp3 b/god/overlord/announce.mp3 Binary files differnew file mode 100644 index 00000000..23bca769 --- /dev/null +++ b/god/overlord/announce.mp3 diff --git a/god/overlord/index b/god/overlord/index new file mode 100755 index 00000000..27506ccd --- /dev/null +++ b/god/overlord/index @@ -0,0 +1,27 @@ +#! /bin/sh +set -euf + +# cd // +cd $(dirname $(readlink -f $0))/../.. + +max=100 +step=10 +min=0 + +# fade-out streams +for i in `seq $max -$step $min`; do + amixer -q -c 0 -D hw:0 sset Front $i% + sleep 0.1 +done +streams/streams stop + +amixer -q -c 0 -D hw:0 sset Front $max% +mplayer god/overlord/announce.mp3 >/dev/null +espeak -v de -s 120 -a 900 "$*" + +# fade-in streams +streams/streams start +for i in `seq $min $step $max`; do + sleep 0.1 + amixer -q -c 0 -D hw:0 sset Front $i% +done |