-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtomatoe.sh
executable file
·76 lines (68 loc) · 1.85 KB
/
tomatoe.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#! /usr/bin/env bash
# File: tomatoe.sh
# What the..?: A simple timer to apply The Pomodoro Technique.
# Who the..?: ksaver (at identi.ca).
# Why? : In the Hope of this little script can be useful...
# When?: July 2010.
# Requieres: bash, play, zenity (nix like OS, of course).
# More Info: http://www.pomodorotechnique.com
# License: Public Domain.
# Not any warranty at all.
#---------------------------------------------------------------
scriptname=$(basename $0 .sh)
scriptvers='0.6'
## --- Set preferences ---
minute=60 # Secs in one min. 60 (habitually).
m_resting=5 # Resting time. Default 05 minutes.
m_working=25 # Working time. Default 25 minutes.
s_resting=$(($m_resting*$minute)) # seconds to resting.
s_working=$(($m_working*$minute)) # seconds to working.
audio_warning="/home/$USER/Audio/attention.wav" # some cute audio warning.
## -----------------------
function starting_dialog()
{
zen_dialog --title "$scriptname - $scriptvers" --question \
--text="Starting Tomatoe Timer:\
\n$m_working Mins Working/$m_resting Mins Resting."
return $?
}
function tomatoe_timer()
{
TASK=$1
LIMIT=$2
COUNT=0
while [ $COUNT -lt $LIMIT ]
do
echo $(($COUNT*100/$LIMIT)) # % percentage %
let COUNT=$COUNT+1
sleep 1
done | zen_dialog --title="Cycles: $count_cycle" --progress --auto-close \
--text="Time to $TASK ($(($LIMIT/$minute)) Mins)...\t"
return $?
}
function zen_alert()
{
play "$audio_warning" & # Decomment if you want a sound warning.
zen_dialog --title="Cycles: $count_cycle" --question \
--text="Time to $1 has Finished!\nShall I Continue?"
return $?
}
function zen_dialog()
{
/usr/bin/env zenity "$@"
}
function __main__()
{
count_cycle=1
starting_dialog || exit
while true
do
tomatoe_timer "Working" $s_working
zen_alert "Working" || exit
tomatoe_timer "Slacking" $s_resting
zen_alert "Slacking" || exit
let count_cycle=$count_cycle+1
done
}
## Run script...
__main__