-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteatime-white
More file actions
executable file
·40 lines (34 loc) · 1.12 KB
/
teatime-white
File metadata and controls
executable file
·40 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash -e
#This script implements the directions for
#brewing white tea as listed on the box
#This function returns after the given seconds
#It displays a simple countdown message
#The message should be a printf style template with
#a %d for the countdown numbers
#usage: countdown 123 'Message %d seconds'
countdown() {
TIMELEFT=$1
BLANK=$( printf ' %.0s' $( seq 1 $(( ${#TIMELEFT} + ${#2} )) ) )
while true ; do
if [[ "0" -le "$TIMELEFT" ]] ; then
MIN=$(( $TIMELEFT / 60 ))
SEC=$(( $TIMELEFT - ($MIN * 60) ))
printf "\r$BLANK\r$2" $MIN $SEC
sleep 1s;
TIMELEFT=$(( $TIMELEFT - 1 ))
else
break
fi
done
}
#Let water cool for 5 minutes
countdown 300 'Let water cool for %dm %ds'
espeak 'The water is now cool enough'
#Steep tea for 2 minutes
countdown 90 'Tea will be steeped in %dm %ds seconds.'
espeak 'Your tea is steeped'
#Wait 5 minutes for the tea to cool
countdown 300 'Tea will be ready to drink in %dm %ds seconds.'
espeak 'Your tea is ready to drink'
#Add an empty line so the prompt appears on a new line
echo