#!/bin/bash # Check we have an input if [ $# -eq 0 ]; then # No inputs given, display help ($0 is the scripts name) echo "Usage $0 delay" echo "e.g. $0 10 will time 10s then flash red" else # Set on (green) and wait echo "020" > /dev/ledborg sleep $1 # Flash red until user presses a key echo "Time's up!" echo "Press any key to finish" key="" while [ "$key" = "" ]; do # Set red and wait for 1 keypress (1 second timeout) echo "200" > /dev/ledborg read -n 1 -t 1 key # If no key was pressed set off and wait for 1 keypress (1 second timeout) if [ "$key" = "" ]; then echo "000" > /dev/ledborg read -n 1 -t 1 key fi done # Set off (we are now done) echo "000" > /dev/ledborg fi