-
Notifications
You must be signed in to change notification settings - Fork 27
/
underwater.sh
51 lines (36 loc) · 1.02 KB
/
underwater.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
#!/bin/bash
VOICE=Alex
function SayMinute {
local s=
[ "$1" -gt 1 ] && s=s
say -v "$VOICE" "$1" minute$s &
}
function SayMiddle {
say -v "$VOICE" half &
}
function PrintTimer {
printf "\r⏰ \033[7m %02d:%02d \033[0m" $1 $2
}
function VolumeUp {
which -s osascript || return
eval "local _$(osascript -e 'get volume settings' | tr ',: ' ' =_' )"
[[ "$_output_muted" == true ]] && osascript -e 'set volume output muted false'
[ $_output_volume -lt 50 ] && osascript -e 'set volume output volume 50'
}
trap 'echo -e "\033[?25h\033[0m"' EXIT
echo -e "\033[?25l"
start=$(date +%s)
echo -e 'Press ^C key to exit and any other key to memory current value.\n'
PrintTimer 0 0
VolumeUp
while true; do
timeout=( $( (time -p read -n1 -t1 -rs) 2>&1) )
[[ ${timeout[1]} != 1* ]] && printf "\n\n"
now=$(date +%s)
per=$(( $now - $start))
sec=$(( $per % 60 ))
min=$(( $per / 60))
[ $sec = 30 ] && SayMiddle
PrintTimer $min $sec
[[ $min > 0 && $sec == 0 ]] && SayMinute $min
done