Skip to content

Instantly share code, notes, and snippets.

@2ec0b4
Created November 21, 2015 21:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2ec0b4/1abf76bc2fed60dad49f to your computer and use it in GitHub Desktop.
Save 2ec0b4/1abf76bc2fed60dad49f to your computer and use it in GitHub Desktop.
KITT grill visual from Knight Rider
#!/bin/bash
vNbLights=9
vWidth=3
vSleep=0.5
function sendRequest() {
nc -w0 -u lights.climagic.com 45444 <<< $1
}
echo "Go to http://lights.climagic.com/ and start the video stream"
while true; do
read -p "Do you want to see KITT in action? [y]/n"
case $yn in
[Nn]* ) exit;;
* ) break;;
esac
done
echo "Turn off all the lights"
sendRequest CLEAR
echo "And GO"
sleep 1
vStart=1
vEnd=$(echo "$vNbLights + $vWidth" | bc)
while true; do
for i in $(seq $vStart $vEnd);
do
vPrev=$(echo "$i - $vWidth" | bc)
if [ $i -le $vNbLights ]; then
vLights="$i"
if [ $vPrev -gt 0 ]; then
vLights="$vLights$vPrev"
fi
else
vLights="$vPrev"
fi
sendRequest $vLights
sleep $vSleep
done
vTmp=$vStart
vStart=$vEnd
vEnd=$vTmp
sleep $vSleep
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment