-
Notifications
You must be signed in to change notification settings - Fork 0
/
productivity-timer
executable file
·83 lines (76 loc) · 2.15 KB
/
productivity-timer
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
package="productivity-timer"
worktime=53
playtime=17
cycles=0
cur_cycle=0
quiet=0
function timer_cycle {
echo "Working - $worktime min, $cur_cycle cycles done"
notify-send "Timer - Start Working" "$worktime min of work left, $cur_cycle cycles done";
sleep $worktime_sec;
if test $quiet -eq 0; then
ffplay -hide_banner -loglevel panic -autoexit -nodisp $HOME/scripts/assets/ding.mp3;
fi
echo "Break - $playtime min, $cur_cycle cycles done"
notify-send "Timer - Break" "You have $playtime min of break remaining";
sleep $playtime_sec;
if test $quiet -eq 0; then
ffplay -hide_banner -loglevel panic -autoexit -nodisp $HOME/scripts/assets/ding.mp3;
fi
}
if test $# -eq 0;
then
echo "$package - simple CLI baser productivity timer"
echo " "
echo "$package [options]"
echo " "
echo "options:"
echo "-w, work cycle in minutes [default 53]"
echo "-p, play cycle in minutes [default 17]"
echo "-c, number of cycles [default unending]"
echo "-q, show the notification silently [default with sound]"
exit 1
fi
while getopts 'w:p:c:q' OPTION; do
case "$OPTION" in
w)
worktime=$OPTARG;
;;
p)
playtime=$OPTARG;
;;
c)
cycles=$OPTARG;
;;
q)
quiet=1;
;;
?)
echo "$package - simple CLI baser productivity timer"
echo " "
echo "$package [options]"
echo " "
echo "options:"
echo "-w, work cycle in minutes [default 53]"
echo "-p, play cycle in minutes [default 17]"
echo "-c, number of cycles [default unending]"
echo "-q, show the notification silently [default with sound]"
exit 1
;;
esac
done
worktime_sec=$(expr $worktime \* 60)
playtime_sec=$(expr $playtime \* 60)
if test $cycles -eq 0;
then
while true; do
timer_cycle;
cur_cycle=$(expr $cur_cycle + 1)
done
else
while test $cur_cycle -lt $cycles ; do
timer_cycle;
cur_cycle=$(expr $cur_cycle + 1)
done
fi