pomodoro: Add a initialize function and introduce SHORT and LONG break

time.
This commit is contained in:
Jeremy Gardais 2015-10-18 12:59:09 +02:00
parent 7b49be2465
commit a9e9e83e15
1 changed files with 22 additions and 13 deletions

View File

@ -3,7 +3,8 @@
TIME=0 TIME=0
# Work on the task (default: 25 min) # Work on the task (default: 25 min)
WORK_TIME=25 WORK_TIME=25
BREAK_TIME=5 SHORT_BREAK_TIME=5
LONG_BREAK_TIME=20
# Log informations # Log informations
LOG_DIR="${HOME}/.pomodoro" LOG_DIR="${HOME}/.pomodoro"
@ -14,8 +15,10 @@ LOG_TASK_PATH="${LOG_DIR}/${LOG_TASK_NAME}"
TASK_NAME="${1}" TASK_NAME="${1}"
TASK_PATH="${LOG_DIR}/current.task" TASK_PATH="${LOG_DIR}/current.task"
initialize() {
# Create the log dir # Create the log dir
if [ ! -f "${LOG_DIR}" ]; then if [ ! -d "${LOG_DIR}" ]; then
mkdir -p -- "${LOG_DIR}" mkdir -p -- "${LOG_DIR}"
fi fi
@ -28,6 +31,11 @@ fi
if [ ! -f "${LOG_TASK_PATH}" ]; then if [ ! -f "${LOG_TASK_PATH}" ]; then
touch "${LOG_TASK_PATH}" touch "${LOG_TASK_PATH}"
fi fi
}
# ------------- START -------------
initialize
# Start working # Start working
startedTime=$(date +"%H:%M") startedTime=$(date +"%H:%M")
@ -45,6 +53,7 @@ done
printf '%b' "$(date +"%A (%F) $startedTime → %H:%M") $TASK_NAME" >> "${LOG_TASK_PATH}" printf '%b' "$(date +"%A (%F) $startedTime → %H:%M") $TASK_NAME" >> "${LOG_TASK_PATH}"
# Start break # Start break
BREAK_TIME=${SHORT_BREAK_TIME}
printf '%b' "BREAK\n${BREAK_TIME}" > "${TASK_PATH}" printf '%b' "BREAK\n${BREAK_TIME}" > "${TASK_PATH}"
while [ "${BREAK_TIME}" > 0 ]; do while [ "${BREAK_TIME}" > 0 ]; do