Better task log management

This commit is contained in:
Yann Esposito (Yogsototh) 2011-07-16 11:11:16 +02:00
parent 2f8347fd3e
commit fe9722f0b8

View file

@ -1,5 +1,13 @@
#!/usr/bin/env zsh
# Here how it is intended to work
# When you start the script, it asks you the name of the task
# Then you work for 25 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).
# Each work session require you enter a name.
# At the end of the day, all your tasks are keep into ~/Documents/Podomoro
# in minutes
WORKING_TIME=25
SHORT_RELAX_TIME=5
@ -23,7 +31,8 @@ function notify() {
esac
}
function ysleep() {
# show timer
function timer() {
m=$1
s=00
while (( m+s > 0 )); do
@ -38,22 +47,51 @@ function ysleep() {
done
}
# Where to keep trak of your documents?
[[ -e $HOME/.podomoro ]] && source $HOME/.podomoro
if ((NO_LOGS)); then
logfile=/dev/null
else
logfiledir=$HOME/Documents/Podomoro
logfilename=$(date +"podomoro-%Y-%m-%d.tasks")
logfile=$logfiledir/$logfilename
while [[ ! -d $logfiledir ]]; do
print -- "$logfiledir does not exists. Would you want to create it? (Y/N)"
read answer
case $answer in
Y|YES|y|yes) mkdir -p $logfiledir || exit 1;;
*) print -- "Enter a full path of directory to write logs or just enter NO to don't keep tasks."
read answer
case $answer in
N|n|NO|no) logfiledir=/dev; logfile=/dev/null;;
*)
logfiledir=$answer;
NO_LOGS=1;
logfile=$logfiledir/$logfilename ;;
esac
{
print -- "logfiledir=$logfiledir"
(( NO_LOGS )) && print -- "NO_LOGS=1"
} > $HOME/.podomoro
;;
esac
done
fi
nb=1
tasks=()
logfile=$(date +"podomoro-%Y-%m-%d.tasks")
while (true) {
notify "Enter the task"
print -- "Title of the task: "
read task
print "$(date +"%H:%M: ") $task" >> $logfile
print -n -- "WORK NOW! "
ysleep WORKING_TIME
print -n "\nTime to take a break: "
notify "Time to take break"
if ((nb % 4 == 0)); then
timer $WORKING_TIME
print -n "\nTime for a break."
notify "Time for a break."
if ((nb++ % 4 == 0)); then
RELAX_TIME=$SHORT_RELAX_TIME
else
RELAX_TIME=$LONG_RELAX_TIME
fi
ysleep $RELAX_TIME
timer $RELAX_TIME
}