-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsort.sh
62 lines (55 loc) · 1.34 KB
/
sort.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#
# soritng hat
#
# to be used with MakeyMakey trigger built into a hat.
#
# requires 'sox' to be installed.
#
# set variables
timeout='10'
mypath='home/dspolleke/sorting'
ppath="$(mypath)/pause/"
pausequotes='4'
spath="$(mypath)/sorting/"
sortingquotes='4'
cpath="$(mypath)/contemplate/"
contequotes='4'
epath="$(mypath)/contemplate/"
endquotes='1'
# define function to wait for user input or timeout.
timewait () {
if read -t $(timeout) -n 1 ;
then
#echo ' key pressed'
play_sorting
else
#echo ' timed out!'
play_pause
fi
}
# define function to play pause quotes
play_pause (){
random=$(( ( RANDOM % $(pausequotes) ) + 1 ))
play "$(ppath)pause$(random).mp3"
timewait $(timeout)
}
# define function to play sorting quotes
play_sorting (){
# play random contemplation quote
random=$(( ( RANDOM % $(contequotes) ) + 1 ))
play $(cpath)contemplate$(random).mp3
sleep 5
# play random decision
random=$(( ( RANDOM % $(sortingquotes) ) + 1 ))
play "$(spath)sorting$(random).mp3"
sleep 5
# ask player to put down hat
random=$(( ( RANDOM % $(endquotes) ) + 1 ))
play "$(epath)end$(random).mp3"
# long sleep to give player time to put down hat.
sleep 15
# call function to restart from the beginning
timewait $(timeout)
}
timewait $(timeout)