#!/bin/sh TIME=0 # Work on the task (default: 25 min) DELAY=25 # Log informations LOG_DIR="${HOME}/.pomodoro" LOG_TASK_NAME=$(date +"week-%V-%Y.txt") LOG_TASK_PATH="${LOG_DIR}/${LOG_TASK_NAME}" # Task information (name, path, …) TASK_NAME="${1}" TASK_PATH="${LOG_DIR}/current.task" # Create the log dir if [ ! -f "${LOG_DIR}" ]; then mkdir -p -- "${LOG_DIR}" fi # Create the task file if [ ! -f "${TASK_PATH}" ]; then touch "${TASK_PATH}" fi # Create the task log file if [ ! -f "${LOG_TASK_PATH}" ]; then touch "${LOG_TASK_PATH}" fi # Start working startedTime=$(date +"%H:%M") # Tiny timer while [ "${TIME}" != "${DELAY}" ] do printf '%b' "${TASK_NAME}\n${TIME}" > "${TASK_PATH}" sleep 1 TIME=$((TIME+1)) done # Write logs printf '%b' "$(date +"%A (%F) $startedTime → %H:%M") $TASK_NAME" >> "${LOG_TASK_PATH}" exit 0