Another podomoro ↔ pomodoro
This commit is contained in:
parent
b90398c99c
commit
24f3c5ec01
2 changed files with 62 additions and 26 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Podomoro
|
# Pomodoro
|
||||||
|
|
||||||
This is a command line tool for the podomoro technique.
|
This is a command line tool for the pomodoro technique.
|
||||||
|
|
||||||
- Work 25 min, relax 5 min.
|
- Work 25 min, relax 5 min.
|
||||||
- Work 25 min, relax 5 min.
|
- Work 25 min, relax 5 min.
|
||||||
|
|
84
pomodoro
84
pomodoro
|
@ -6,19 +6,21 @@
|
||||||
# Once finished you are notified it is time to take a break (5 min).
|
# Once finished you are notified it is time to take a break (5 min).
|
||||||
# After 4 work sessions, you take a longer break (30 min).
|
# After 4 work sessions, you take a longer break (30 min).
|
||||||
# Each work session require you enter a name.
|
# Each work session require you enter a name.
|
||||||
# At the end of the day, all your tasks are keep into ~/Documents/Podomoro
|
# At the end of the day, all your tasks are keep into ~/Documents/Pomodoro
|
||||||
|
|
||||||
PODOMORO_NO_LOGS=0
|
POMODORO_NO_LOGS=0
|
||||||
# in minutes
|
POMODORO_LOG_DIRECTORY="$HOME/Documents/Pomodoro"
|
||||||
PODOMORO_WORKING_TIME=25
|
|
||||||
PODOMORO_SHORT_RELAX_TIME=5
|
# times are in minutes
|
||||||
PODOMORO_LONG_RELAX_TIME=30
|
POMODORO_WORKING_TIME=25
|
||||||
|
POMODORO_SHORT_RELAX_TIME=5
|
||||||
|
POMODORO_LONG_RELAX_TIME=30
|
||||||
|
|
||||||
function notify() {
|
function notify() {
|
||||||
print -n -- "$*"
|
print -n -- "$*"
|
||||||
|
|
||||||
if [[ "$PODOMORO_NOTIFY" != "" ]]; then
|
if [[ "$POMODORO_NOTIFY" != "" ]]; then
|
||||||
eval $( echo $PODOMORO_NOTIFY | sed 's/%m/"'$message'"/g' )
|
eval $( echo $POMODORO_NOTIFY | sed 's/%m/"'$message'"/g' )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -44,9 +46,9 @@ function notify() {
|
||||||
;;
|
;;
|
||||||
*) {
|
*) {
|
||||||
print -- "I don't made a notification system for your system"
|
print -- "I don't made a notification system for your system"
|
||||||
print -- "You can use the \$HOME/.podomoro file to declare your own notification system"
|
print -- "You can use the \$HOME/.pomodoro file to declare your own notification system"
|
||||||
print -- "For example: "
|
print -- "For example: "
|
||||||
print -- "PODOMORO_NOTIFY=\"notify_cmd --message=%m\""
|
print -- "POMODORO_NOTIFY=\"notify_cmd --message=%m\""
|
||||||
print
|
print
|
||||||
print -- "Then it will be executed as \"notify_cmd\" --message=\"notification message\""
|
print -- "Then it will be executed as \"notify_cmd\" --message=\"notification message\""
|
||||||
} >&2
|
} >&2
|
||||||
|
@ -101,14 +103,17 @@ funtion posttimer() {
|
||||||
# Where to keep trak of your documents?
|
# Where to keep trak of your documents?
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
# read the .podomoro file if it exists
|
# read the .pomodoro file if it exists
|
||||||
[[ -e $HOME/.podomoro ]] && source $HOME/.podomoro
|
[[ -e $HOME/.pomodoro ]] && source $HOME/.pomodoro
|
||||||
if ((PODOMORO_NO_LOGS)); then
|
|
||||||
|
if ((POMODORO_NO_LOGS)); then
|
||||||
logfile=/dev/null
|
logfile=/dev/null
|
||||||
else
|
else
|
||||||
logfiledir=$HOME/Documents/Podomoro
|
# Verify where to write podomoro logs
|
||||||
|
logfiledir=$HOME/Documents/Pomodoro
|
||||||
logfilename=$(date +"week-%V.txt")
|
logfilename=$(date +"week-%V.txt")
|
||||||
logfile=$logfiledir/$logfilename
|
logfile=$logfiledir/$logfilename
|
||||||
|
|
||||||
while [[ ! -d $logfiledir ]]; do
|
while [[ ! -d $logfiledir ]]; do
|
||||||
print -- "$logfiledir does not exists. Would you want to create it? (y/n)"
|
print -- "$logfiledir does not exists. Would you want to create it? (y/n)"
|
||||||
read answer
|
read answer
|
||||||
|
@ -126,32 +131,63 @@ function initialize() {
|
||||||
{
|
{
|
||||||
print -- "logfiledir=$logfiledir"
|
print -- "logfiledir=$logfiledir"
|
||||||
(( NO_LOGS )) && print -- "NO_LOGS=1"
|
(( NO_LOGS )) && print -- "NO_LOGS=1"
|
||||||
} > $HOME/.podomoro
|
} > $HOME/.pomodoro
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nb=1
|
typeset -U lastTasks
|
||||||
initialize
|
function askTitle() {
|
||||||
while (true) {
|
((${#lastTasks})) && print
|
||||||
|
i=1;
|
||||||
|
print
|
||||||
|
for task in $lastTasks; do
|
||||||
|
print "$i) $task"
|
||||||
|
((i++))
|
||||||
|
done
|
||||||
notify "Enter the title of the task: "
|
notify "Enter the title of the task: "
|
||||||
read task
|
read task
|
||||||
|
|
||||||
|
if print -- $task | grep -e '^[0-9][0-9]*$' >/dev/null; then
|
||||||
|
if (( task <= ${#lastTasks} )); then
|
||||||
|
task="${lastTasks[$task]}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
lastTasks=( $lastTasks "$task" )
|
||||||
|
}
|
||||||
|
|
||||||
|
nb=1
|
||||||
|
|
||||||
|
# readArguments $*
|
||||||
|
|
||||||
|
initialize
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
# Ask the user the title of the task
|
||||||
|
askTitle
|
||||||
|
|
||||||
|
# Start working
|
||||||
startedTime=$(date +"%H:%M")
|
startedTime=$(date +"%H:%M")
|
||||||
# print "$(date +"%A (%F) %H:%M → ") $task" >> $logfile
|
|
||||||
print -n -- "WORK NOW! "
|
print -n -- "WORK NOW! "
|
||||||
if timer $PODOMORO_WORKING_TIME; then
|
if timer $POMODORO_WORKING_TIME; then
|
||||||
notify "Time for a break. "
|
notify "Time for a break. "
|
||||||
posttimer
|
posttimer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# work is finished
|
||||||
print "$(date +"%A (%F) $startedTime → %H:%M") $task" >> $logfile
|
print "$(date +"%A (%F) $startedTime → %H:%M") $task" >> $logfile
|
||||||
|
|
||||||
|
# Time for a break
|
||||||
if ((nb++ % 4 == 0)); then
|
if ((nb++ % 4 == 0)); then
|
||||||
PODOMORO_RELAX_TIME=$PODOMORO_LONG_RELAX_TIME
|
notify "Long pause "
|
||||||
|
POMODORO_RELAX_TIME=$POMODORO_LONG_RELAX_TIME
|
||||||
else
|
else
|
||||||
PODOMORO_RELAX_TIME=$PODOMORO_SHORT_RELAX_TIME
|
notify "Relax "
|
||||||
|
POMODORO_RELAX_TIME=$POMODORO_SHORT_RELAX_TIME
|
||||||
fi
|
fi
|
||||||
notify "PAUSE "
|
timer $POMODORO_RELAX_TIME
|
||||||
timer $PODOMORO_RELAX_TIME
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue