-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpomodoro
executable file
·87 lines (74 loc) · 1.8 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#
# @Time-stamp: <2010-12-29 10:33:59 ferk>
# @Author: Fernando Carmona Varo
#---
# Script to show notifications on pomodoro timeout, useful to follow the
# pomodoro technique book about improving productivity, or as a
# multi-purpose timer (the coundown minutes can be set as arguments).
#
# [[Pomodoro Technique][ http://www.pomodorotechnique.com/ ]]
#---
function notificate() {
beep -f 1000 -r 2 -n -r 5 -l 10 -n &
notify-send -u critical -i appointment -t 2000 "$@" || \
echo "tell app \"System Events\" to display dialog \"$@\"" | osascript
echo "$@"
}
function pomodoro-call() {
mins="$1"
endmessage="$2"
startmessage="$3"
## Load default values
if [ -z $mins ]
then
mins=25
fi
if [ -z $endmessage ]
then
startmessage="You have $mins minutes left"
fi
if [ -z $endmessage ]
then
endmessage="Please stop the work and take a short break"
fi
notificate "Pomodoro started!" "$startmessage"
while [ $mins != 0 ]; do
sleep 60
let "mins = $mins - 1"
echo "$mins minutes left";
done
notificate "Pomodoro ended!" "$endmessage"
}
case "$1" in
"stop")
echo "Stopping pomodoro processes..."
pkill -STOP -f "$0 *[1-9]"
if [ "$?" = "0" ]
then
$notificate "All pomodoros stopped!" "To make them continue, run \"pomodoro cont\""
else
echo "Couldn't stop any pomodoro process (no pomodoro running?)"
fi
exit
;;
"cont")
echo "Resuming pomodoro processes..."
pkill -CONT -f "$0 *[1-9]"
if [ "$?" = "0" ]
then
$notificate "All pomodoros resumed!" "The counters will continue as if nothing happened"
else
echo "Couldn't resume any pomodoro process (no pomodoro found?)"
fi
exit
;;
[123456789]*)
pomodoro-call $@
;;
"")
pomodoro-call 25
;;
*)
echo "Usage: pomodoro [ stop | cont | minutes [endmessage] [startmessage] ]"
esac