Fixed a small bug
This commit is contained in:
parent
dca23708b4
commit
597ca68e42
1 changed files with 47 additions and 26 deletions
73
pomodoro
73
pomodoro
|
@ -23,20 +23,25 @@ POMODORO_LONG_RELAX_TIME=30
|
||||||
# If you want to block some popular website
|
# If you want to block some popular website
|
||||||
# during your work session.
|
# during your work session.
|
||||||
# not you can overide these functions in $HOME/.pomodoro
|
# not you can overide these functions in $HOME/.pomodoro
|
||||||
pomodoro_work_started() {
|
|
||||||
|
function focus_on() {
|
||||||
[[ -x =get-shit-done ]] && {
|
[[ -x =get-shit-done ]] && {
|
||||||
sudo =get-shit-done work
|
sudo =get-shit-done work
|
||||||
print -- "[focus on]"
|
print -- "[focus on]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pomodoro_work_time_ended() {}
|
function focus_off() {
|
||||||
pomodoro_pause_started() {
|
[[ -x =get-shit-done ]] && {
|
||||||
[[ -x =get-shit-done ]] && sudo =get-shit-done play
|
sudo =get-shit-done play
|
||||||
}
|
print -- "[focus off]"
|
||||||
pomodoro_pause_time_ended() {
|
}
|
||||||
pomodoro_work_started
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pomodoro_work_started() { focus_on }
|
||||||
|
function pomodoro_work_time_ended() {}
|
||||||
|
function pomodoro_pause_started() { focus_off }
|
||||||
|
function pomodoro_pause_time_ended() { focus_on }
|
||||||
|
|
||||||
# used to list latests task names
|
# used to list latests task names
|
||||||
typeset -U latestTasks
|
typeset -U latestTasks
|
||||||
typeset -U todoTasks
|
typeset -U todoTasks
|
||||||
|
@ -102,7 +107,6 @@ function notify() {
|
||||||
# And the counter grow.
|
# And the counter grow.
|
||||||
function timer() {
|
function timer() {
|
||||||
local timeToWait=$1
|
local timeToWait=$1
|
||||||
shift
|
|
||||||
local message="$2"
|
local message="$2"
|
||||||
local triggerCmd="$3"
|
local triggerCmd="$3"
|
||||||
if pretimer $timeToWait; then
|
if pretimer $timeToWait; then
|
||||||
|
@ -149,6 +153,7 @@ funtion posttimer() {
|
||||||
if ((s>59)); then
|
if ((s>59)); then
|
||||||
((s=0))
|
((s=0))
|
||||||
((m++))
|
((m++))
|
||||||
|
print
|
||||||
notify "$message"
|
notify "$message"
|
||||||
fi
|
fi
|
||||||
printf "$rem+%02d:%02d" $m $s
|
printf "$rem+%02d:%02d" $m $s
|
||||||
|
@ -181,6 +186,8 @@ function initTodoTasksFromFile() {
|
||||||
|
|
||||||
# Which file to track your activity?
|
# Which file to track your activity?
|
||||||
function initialize() {
|
function initialize() {
|
||||||
|
# nb is the number of loop we already done
|
||||||
|
nb=1
|
||||||
# read the .pomodoro file if it exists
|
# read the .pomodoro file if it exists
|
||||||
[[ -e $HOME/.pomodoro ]] && source $HOME/.pomodoro
|
[[ -e $HOME/.pomodoro ]] && source $HOME/.pomodoro
|
||||||
|
|
||||||
|
@ -224,9 +231,10 @@ function initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# ask the title of the tasks
|
# ask the title of the tasks
|
||||||
|
# And present previous tasks and TODO
|
||||||
function askTitle() {
|
function askTitle() {
|
||||||
((${#latestTasks})) && print
|
((${#latestTasks})) && print -P -- "%Bworked tasks%b"
|
||||||
i=1;
|
local i=1;
|
||||||
print
|
print
|
||||||
for task in $latestTasks; do
|
for task in $latestTasks; do
|
||||||
print -- "$i) $task"
|
print -- "$i) $task"
|
||||||
|
@ -262,23 +270,10 @@ function askTitle() {
|
||||||
latestTasks=( $latestTasks "$task" )
|
latestTasks=( $latestTasks "$task" )
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize
|
|
||||||
|
|
||||||
nb=1;
|
# first 3 pauses are short ones
|
||||||
while (true) {
|
# the 4th is a long one
|
||||||
# Ask the user the title of the task
|
function compute_pause_time() {
|
||||||
askTitle
|
|
||||||
|
|
||||||
# Start working
|
|
||||||
startedTime=$(date +"%H:%M")
|
|
||||||
print -n -- "WORK NOW! "
|
|
||||||
pomodoro_work_started
|
|
||||||
timer $POMODORO_WORKING_TIME "Time for a break." pomodoro_work_time_ended
|
|
||||||
|
|
||||||
# work is finished
|
|
||||||
print "$(date +"%A (%F) $startedTime → %H:%M") $task" >> $logfile
|
|
||||||
|
|
||||||
# Time for a break
|
|
||||||
if ((nb++ % 4 == 0)); then
|
if ((nb++ % 4 == 0)); then
|
||||||
notify "Long pause "
|
notify "Long pause "
|
||||||
POMODORO_RELAX_TIME=$POMODORO_LONG_RELAX_TIME
|
POMODORO_RELAX_TIME=$POMODORO_LONG_RELAX_TIME
|
||||||
|
@ -286,6 +281,32 @@ while (true) {
|
||||||
notify "Relax "
|
notify "Relax "
|
||||||
POMODORO_RELAX_TIME=$POMODORO_SHORT_RELAX_TIME
|
POMODORO_RELAX_TIME=$POMODORO_SHORT_RELAX_TIME
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------- START -------------
|
||||||
|
|
||||||
|
initialize
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
# Ask the user the title of the task
|
||||||
|
askTitle
|
||||||
|
|
||||||
|
# Start working
|
||||||
|
startedTime=$(date +"%H:%M")
|
||||||
|
|
||||||
|
# notification isn't needed
|
||||||
|
print -n -- "WORK NOW! "
|
||||||
|
|
||||||
|
pomodoro_work_started
|
||||||
|
timer $POMODORO_WORKING_TIME "Time for a break." pomodoro_work_time_ended
|
||||||
|
# Task finished
|
||||||
|
|
||||||
|
# Write logs
|
||||||
|
print "$(date +"%A (%F) $startedTime → %H:%M") $task" >> $logfile
|
||||||
|
|
||||||
|
# Time for a break
|
||||||
|
compute_pause_time
|
||||||
|
|
||||||
pomodoro_pause_started
|
pomodoro_pause_started
|
||||||
timer $POMODORO_RELAX_TIME "Time to work!" pomodoro_pause_time_ended
|
timer $POMODORO_RELAX_TIME "Time to work!" pomodoro_pause_time_ended
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue