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