Better task log management
This commit is contained in:
parent
2f8347fd3e
commit
fe9722f0b8
1 changed files with 46 additions and 8 deletions
54
podomoro.sh
54
podomoro.sh
|
@ -1,5 +1,13 @@
|
||||||
#!/usr/bin/env zsh
|
#!/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
|
# in minutes
|
||||||
WORKING_TIME=25
|
WORKING_TIME=25
|
||||||
SHORT_RELAX_TIME=5
|
SHORT_RELAX_TIME=5
|
||||||
|
@ -23,7 +31,8 @@ function notify() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function ysleep() {
|
# show timer
|
||||||
|
function timer() {
|
||||||
m=$1
|
m=$1
|
||||||
s=00
|
s=00
|
||||||
while (( m+s > 0 )); do
|
while (( m+s > 0 )); do
|
||||||
|
@ -38,22 +47,51 @@ function ysleep() {
|
||||||
done
|
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
|
nb=1
|
||||||
tasks=()
|
|
||||||
logfile=$(date +"podomoro-%Y-%m-%d.tasks")
|
|
||||||
while (true) {
|
while (true) {
|
||||||
notify "Enter the task"
|
notify "Enter the task"
|
||||||
print -- "Title of the task: "
|
print -- "Title of the task: "
|
||||||
read task
|
read task
|
||||||
print "$(date +"%H:%M: ") $task" >> $logfile
|
print "$(date +"%H:%M: ") $task" >> $logfile
|
||||||
print -n -- "WORK NOW! "
|
print -n -- "WORK NOW! "
|
||||||
ysleep WORKING_TIME
|
timer $WORKING_TIME
|
||||||
print -n "\nTime to take a break: "
|
print -n "\nTime for a break."
|
||||||
notify "Time to take break"
|
notify "Time for a break."
|
||||||
if ((nb % 4 == 0)); then
|
if ((nb++ % 4 == 0)); then
|
||||||
RELAX_TIME=$SHORT_RELAX_TIME
|
RELAX_TIME=$SHORT_RELAX_TIME
|
||||||
else
|
else
|
||||||
RELAX_TIME=$LONG_RELAX_TIME
|
RELAX_TIME=$LONG_RELAX_TIME
|
||||||
fi
|
fi
|
||||||
ysleep $RELAX_TIME
|
timer $RELAX_TIME
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue