This should be run on boot with sudo privileges.
#!/bin/bash BUTTON=16 PWR=21 LED=5 COMMANDS=("lp -o fit-to-page 1.jpg" "lp -o fit-to-page 2.jpg" "lp -o fit-to-page 3.jpg" "lp -o fit-to-page 4.jpg" "lp -o fit-to-page 5.jpg" "lp -o fit-to-page 6.jpg" "lp -o fit-to-page 7.jpg" "lp -o fit-to-page 8.jpg" "lp -o fit-to-page 9.jpg" "lp -o fit-to-page 10.jpg" "lp -o fit-to-page 11.jpg" "lp -o fit-to-page 11.jpg" "lp -o fit-to-page 12.jpg" "lp -o fit-to-page 13.jpg" "lp -o fit-to-page 14.jpg" "lp -o fit-to-page 15.jpg" "lp -o fit-to-page 16.jpg" # initialize serial printer serial0 at 19200 baud stty -F /dev/serial0 19200 # initialize GPIO state gpio -g mode $BUTTON up gpio -g mode $PWR up gpio -g mode $LED out for i in `seq 1 5`; do gpio -g write $LED 1 sleep 1 gpio -g write $LED 0 sleep 1 done while : do # check for button press if [ $(gpio -g read $BUTTON) -eq 0 ]; then $(shuf -n1 -e "${COMMANDS[@]}") echo | echo | echo | lp #sleep 1 # wait for user to release button before continuing while [ $(gpio -g read $BUTTON) -eq 0 ]; do continue; done fi # check for shutdown switch if [ $(gpio -g read $PWR) -eq 0 ]; then # Must be held for 2+ seconds before shutdown is run... starttime=$(date +%s) while [ $(gpio -g read $PWR) -eq 0 ]; do if [ $(($(date +%s)-starttime)) -ge 2 ]; then sudo shutdown -h fi done fi done
Watch the Full Episode:
Episode 365: Twilight Zone Fortune Telling Machine
More Supplemental Content:
Project: Serling [OUTTAKES] (and an Apple rant)
Adobe InDesign Files For Project Serling