From 77ba054b1e3a55a54f4643bc544e7c3550006a00 Mon Sep 17 00:00:00 2001 From: momo Date: Fri, 23 Sep 2011 17:26:45 +0200 Subject: //god/licht: minor code improvements --- god/licht | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'god/licht') diff --git a/god/licht b/god/licht index cbff9ad0..cd67d338 100755 --- a/god/licht +++ b/god/licht @@ -13,9 +13,11 @@ # ghetto - toggles the lights in the hallway # 0-7 - toggles individual lights +TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` + 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'` + #TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` if ! [ "$LAMPE" -a "$TOGGLE" ];then echo "you are made of stupid" exit 1 @@ -76,38 +78,30 @@ case "$1" in echo "Usage: lich <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 ;; *) -- cgit v1.2.3 From 67cbf3751c594aea88a71e350259943370b51b5f Mon Sep 17 00:00:00 2001 From: root Date: Sat, 24 Sep 2011 19:12:23 +0200 Subject: //god/licht: add long help for noise --- god/licht | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'god/licht') diff --git a/god/licht b/god/licht index cd67d338..9284f622 100755 --- a/god/licht +++ b/god/licht @@ -14,18 +14,39 @@ # 0-7 - toggles individual lights TOGGLE=`echo "$2" | sed -n '/^[0-1]/p'` +shorthelp() { + echo "Usage: $0 [OPTIONS] [0|1]" + echo "Toggle the lights in the shack." +} +longhelp(){ + shorthelp + +cat < <0/1>" + longhelp + exit 1 else echo "Toggle light $LAMPE ($TOGGLE)" printf "$STRING" | nc -u -w1 licht.shack 1337 @@ -73,9 +94,11 @@ porsche(){ } case "$1" in - --help) - echo "Toggle the lights" - echo "Usage: lich <0/1>" + (--help) + if [ "$2" == "--verbose" ] + then longhelp + else shorthelp + fi ;; all) toggle_all -- cgit v1.2.3 From 53679fedeb1db9d68399638fc44aa4cf4ac5ee1c Mon Sep 17 00:00:00 2001 From: momo Date: Sat, 24 Sep 2011 19:28:07 +0200 Subject: //god/licht: add abstraction for specific toggles --- god/licht | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'god/licht') diff --git a/god/licht b/god/licht index 9284f622..12e4555f 100755 --- a/god/licht +++ b/god/licht @@ -56,7 +56,7 @@ toggle() { toggle_all() { for i in `seq 0 7` do - printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + toggle $i $TOGGLE done wait } @@ -64,7 +64,7 @@ toggle_all() { kuschel(){ for i in 0 2 do - printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + toggle $i $TOGGLE done wait } @@ -72,7 +72,7 @@ kuschel(){ software(){ for i in 1 3 do - printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + toggle $i $TOGGLE done wait } @@ -80,17 +80,19 @@ software(){ tische(){ for i in 4 6 do - printf "\\xA5\\x5A\\x$i\\x$TOGGLE" | nc -u -w1 licht.shack 1337 & + toggle $i $TOGGLE done wait } ghetto(){ - printf "\\xA5\\x5A\\x7\\x$TOGGLE" | nc -u -w1 licht.shack 1337 + i=7 + toggle $i $TOGGLE } porsche(){ - printf "\\xA5\\x5A\\x5\\x$TOGGLE" | nc -u -w1 licht.shack 1337 + i=5 + toggle $i $TOGGLE } case "$1" in -- cgit v1.2.3