Skip to content

Instantly share code, notes, and snippets.

@jomat
Created December 17, 2011 14:17
Show Gist options
  • Save jomat/1490317 to your computer and use it in GitHub Desktop.
Save jomat/1490317 to your computer and use it in GitHub Desktop.
Script for our sandwichmaker
#/bin/zsh
# v0.1 jomat 2011-12-16 created makefile
# v0.2 ssc 2011-12-17 added toilet infos
# v0.3 sepi 2011-12-17 outsourced to shell script, catches ctrl_c
# v0.4 ssc 2011-12-17 added 2min user timeout and speech stuff (speak,shout)
#jmt learn to readable code :)
trap ctrl_c INT
function sm_off() {
sispmctl -t 1 >/dev/null
}
function sm_on() {
sispmctl -o 1 >/dev/null
}
function ctrl_c() {
sm_off
exit -1
}
function flite() {
ping -c 1 fukushima 2>/dev/null >/dev/null && (
ssh core@fukushima mpc pause;
ssh core@fukushima aumix -S;
ssh core@fukushima aumix -v $1;
ssh core@fukushima flite -t '$2';
ssh core@fukushima aumix -L;
ssh core@fukushima mpc play;
)&
}
function speak() {
flite 90 "$1"
echo "$1";
}
function shout() {
flite 80 "$2"
toilet --$1 "$2";
}
if [ x"$(whoami)" != x"root" ]; then
speak "What? Make it yourself."
else
if [ x"$(sispmctl -q -n -m 1)" == x"1" ]; then
speak "too busy - aborted current run";
sispmctl -t 1;
else
speak "Okay."
sm_on
for i in $(seq 60 -10 1); do
echo "initializing heatplates ... $i seconds to go";
sleep 10;
done;
speak metal 'INSERT SANDWICH';
echo "press ENTER to continue";
read -t 120 || (
shout "timed out after 120 seconds - aborted current run";
sm_off
)
for i in $(seq 110 -10 1); do
echo "linking bread ... $i seconds to go";
sleep 10;
done;
sm_off
speak gay 'BON APPETIT'
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment