From 9050060c45918aacbe4c488d14f0a6846fd98a1c Mon Sep 17 00:00:00 2001 From: Gardouille Date: Sun, 18 Oct 2015 13:05:39 +0200 Subject: [PATCH] pomodoro: Set a long break if the task list is modulo 4. --- pomodoro.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pomodoro.sh b/pomodoro.sh index ab5627d..d39c521 100755 --- a/pomodoro.sh +++ b/pomodoro.sh @@ -4,6 +4,7 @@ TIME=0 # Work on the task (default: 25 min) WORK_TIME=25 SHORT_BREAK_TIME=5 +# Every 4 pomodori LONG_BREAK_TIME=20 # Log informations @@ -16,7 +17,6 @@ TASK_NAME="${1}" TASK_PATH="${LOG_DIR}/current.task" initialize() { - # Create the log dir if [ ! -d "${LOG_DIR}" ]; then mkdir -p -- "${LOG_DIR}" @@ -50,16 +50,24 @@ while [ "${TIME}" != "${WORK_TIME}" ]; do done # Write logs -printf '%b' "$(date +"%A (%F) $startedTime → %H:%M") $TASK_NAME" >> "${LOG_TASK_PATH}" +printf '%b' "$(date +"%A (%F) $startedTime → %H:%M") $TASK_NAME\n" >> "${LOG_TASK_PATH}" # Start break +if [ `expr ${num} % 4` -eq 0 ]; then + BREAK_TIME=${LONG_BREAK_TIME} + BREAK_MSG="Relax" +else + BREAK_TIME=${SHORT_BREAK_TIME} + BREAK_MSG="Pause" +fi + BREAK_TIME=${SHORT_BREAK_TIME} -printf '%b' "BREAK\n${BREAK_TIME}" > "${TASK_PATH}" +printf '%b' "${BREAK_MSG}\n${BREAK_TIME}" > "${TASK_PATH}" while [ "${BREAK_TIME}" > 0 ]; do sleep 60 BREAK_TIME=$((BREAK_TIME-1)) -printf '%b' "BREAK\n${BREAK_TIME}" > "${TASK_PATH}" + printf '%b' "${BREAK_MSG}\n${BREAK_TIME}" > "${TASK_PATH}" done exit 0