diff --git a/resume.awk b/pomodoro-resume.awk similarity index 80% rename from resume.awk rename to pomodoro-resume.awk index ec98385..439e6e3 100755 --- a/resume.awk +++ b/pomodoro-resume.awk @@ -32,7 +32,10 @@ function message(){ # Print the result END { + maxlen=0; + for (i in time) { + if (length(i)>maxlen) { maxlen=length(i); } } for(i in time) { - print i"\t:\t"timeFromMin(time[i]); + printf "%-"maxlen"s: %s\n",i,timeFromMin(time[i]); } } diff --git a/pomodoro-week-resume b/pomodoro-week-resume new file mode 100755 index 0000000..af7fda9 --- /dev/null +++ b/pomodoro-week-resume @@ -0,0 +1,61 @@ +#!/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/Pomodoro + +POMODORO_NO_LOGS=0 +POMODORO_LOG_DIRECTORY="$HOME/Documents/Pomodoro" +# if you add a TODO.txt file in $POMODORO_LOG_DIRECTORY +# The list of TODO is presented for shortcut +POMODORO_TODO_FILE="$POMODORO_LOG_DIRECTORY/TODO.txt" + +# used to list latests task names +typeset -U latestTasks +typeset -U todoTasks + +function showConfMessage() { + print -- "You can use the \$HOME/.pomodoro file to declare your own notification system" + print -- "For example you could add: " + print -- "POMODORO_NOTIFY=\"notify_cmd --message=%m\"" + print + print -- "Then notification will be executed as \"notify_cmd\" --message=\"notification message\"" +} + +# Which file to track your activity? +function initialize() { + # read the .pomodoro file if it exists + [[ -e $HOME/.pomodoro ]] && source $HOME/.pomodoro + + if ((POMODORO_NO_LOGS)); then + exit + fi + # Verify where to write podomoro logs + logfiledir="$POMODORO_LOG_DIRECTORY" + logfilename=$(date +"week-%V-%Y.txt") + + case $(uname) in + Linux) lastweeklogfilename=$(date -d 'last week' +"week-%V-%Y.txt");; + *) lastweeklogfilename=$(date -v-7d +"week-%V-%Y.txt");; + esac + logfile=$logfiledir/$logfilename + lastweeklogfile=$logfiledir/$lastweeklogfilename +} + +# ------------- START ------------- +initialize + +if [[ -r $lastweeklogfile ]]; then + print -P -- "%B$lastweeklogfilename%b" + pomodoro-resume.awk $lastweeklogfile + print +fi + +if [[ -r $logfile ]]; then + print -P -- "%B$logfilename%b" + pomodoro-resume.awk $logfile +fi