Difference between revisions of "5mof tools"

From Noisebridge
Jump to: navigation, search
(Created page with "=== html 5 timers === - http://hackandtell.org/timer/")
 
Line 2: Line 2:
  
 
  - http://hackandtell.org/timer/
 
  - http://hackandtell.org/timer/
 +
 +
=== flaschentaschen and mary poppins control script ===
 +
 +
<pre>
 +
#!/bin/bash
 +
 +
set -e
 +
 +
HOST=localhost
 +
if [ -n "$1" ]; then
 +
    HOST="$1"
 +
fi
 +
 +
 +
display () {
 +
    convert -size 45x35 \
 +
    -colors 256 -depth 8 \
 +
    -background "$2" -fill white \
 +
    -gravity center \
 +
    -font Noto-Sans -pointsize 12 label:"$1" \
 +
    timer.png
 +
    pngtopnm timer.png > timer.pnm
 +
    { cat timer.pnm; \
 +
      echo 0 0 10; \
 +
    } | cat > /dev/udp/$HOST/1337
 +
}
 +
 +
MINS=5
 +
SECS=0
 +
COLOR='green'
 +
 +
lower () {
 +
    if [ "$MINS" -eq 0 ]; then
 +
COLOR=red
 +
    fi
 +
    if [ "$SECS" -eq 0 ]; then
 +
if [ "$MINS" -eq 0 ]; then
 +
    echo "done!"
 +
    curl -XPOST http://pegasus.noise:5000/ -d "text=your five minutes of fame are over"
 +
    exit 0
 +
else
 +
    MINS="$((MINS - 1))"
 +
    SECS=59
 +
fi
 +
    else
 +
SECS="$((SECS - 1))"
 +
    fi
 +
}
 +
 +
 +
while true; do
 +
    echo "$MINS:$SECS"
 +
    display $(printf "%02d:%02d" "$MINS" "$SECS") "$COLOR"
 +
    lower
 +
    sleep 1
 +
done
 +
 +
</pre>
 +
-lizzie

Revision as of 05:52, 30 November 2016

html 5 timers

- http://hackandtell.org/timer/

flaschentaschen and mary poppins control script

#!/bin/bash

set -e

HOST=localhost
if [ -n "$1" ]; then
    HOST="$1"
fi


display () {
    convert -size 45x35 \
	    -colors 256 -depth 8 \
	    -background "$2" -fill white \
	    -gravity center \
	    -font Noto-Sans -pointsize 12 label:"$1" \
	    timer.png
    pngtopnm timer.png > timer.pnm
    { cat timer.pnm; \
      echo 0 0 10; \
    } | cat > /dev/udp/$HOST/1337
}

MINS=5
SECS=0
COLOR='green'

lower () {
    if [ "$MINS" -eq 0 ]; then
	COLOR=red
    fi
    if [ "$SECS" -eq 0 ]; then
	if [ "$MINS" -eq 0 ]; then
	    echo "done!"
	    curl -XPOST http://pegasus.noise:5000/ -d "text=your five minutes of fame are over"
	    exit 0
	else
	    MINS="$((MINS - 1))"
	    SECS=59
	fi
    else
	SECS="$((SECS - 1))"
    fi
}


while true; do
    echo "$MINS:$SECS"
    display $(printf "%02d:%02d" "$MINS" "$SECS") "$COLOR"
    lower
    sleep 1
done

-lizzie