-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpomodoro
executable file
·66 lines (57 loc) · 1.29 KB
/
pomodoro
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
63
64
65
66
#!/bin/bash
#pomodoro
workLength=1500
restLength=300
recordTomato () {
notify-send "break"
_alarm
exec 3>&1
didwhat=$(dialog --inputbox 'What did you do?' 0 0 2>&1 1>&3)
exitcode=$?;
exec 3>&-;
echo "`date +%D:%T` Task: $didwhat" >> pomodoro.log
runBreak
}
runTomato () {
dialog --title "Pomodoro" --yesno "Do you want to start a tomato?" 0 0
exitcode=$?;
if [ $exitcode = 0 ] ; then
date1=$((`date +%s` + workLength));
while [ "$date1" -ge `date +%s` ];
do
dialog --infobox "Work for $(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)" 10 30 ; sleep 1
done
recordTomato
else
dialog --infobox "Thanks for playing the tomato game. " 0 0
echo "done"
exit 0
fi
}
runBreak () {
date1=$((`date +%s` + restLength));
countTomato
while [ "$date1" -ge `date +%s` ];
do
dialog --infobox "Nice work; you did:
$didwhat
Now you're on break!
rest for $(date -u --date @$(($date1 - `date +%s` )) +%H:%M:%S)
You've completed $tomatoCount tomatoes today." 0 0 ; sleep 1
done
notify-send "Start tomato"
_alarm
runTomato
}
countTomato() {
tomatoCount=0
while IFS='' read -r line || [[ -n "$line" ]]; do
if [ "${line:0:8}" == "`date +%D`" ]; then
tomatoCount=$(($tomatoCount+1))
fi;
done < pomodoro.log;
}
_alarm() {
( speaker-test -t sine -f 1000 )& pid=$! ; sleep 0.1s ; kill -9 $pid
}
runTomato