Add pomodorrior.

This commit is contained in:
gardouille 2017-01-16 16:46:23 +01:00
parent 003bf25c09
commit be8ed4163e
2 changed files with 91 additions and 0 deletions

View File

@ -12,6 +12,7 @@ Some useful scripts (for me) that can be added to $PATH :)
* flac_to_mp3: convert all flac files of a directory into mp3.
* launch_thyme: Launch Thyme - apps tracker.
* num_circle: Transform a number into a digit with a circle.
* pomodorrior: A tiny pomodoro's timer for Taskwarrior.
* pomodoro: Print a task and a timer in a file. Try to apply Pomodoro Technique!
* snapsend.sh: Send a ZFS snapshot to a remote host.
* tag_photo.sh: Add an exif tag to images.
@ -72,6 +73,16 @@ num_circle 18
```
### Pomodorrior
A tiny timer to use the Pomodoro technique with Taskwarrior.
The script will:
* Create the task if it doesn't exists.
* Start the task for 25 minutes (default time).
* Start a break time for 5 minutes (default time).
All informations will be printed in the Taskwarrior's directory: **${HOME}/.task/.current.task** so you can then parse and print the content of this file into your systray, tmux's statusbar,…
### Pomodoro
My implementation of the Pomodoro Technique (https://en.wikipedia.org/wiki/Pomodoro_Technique).

80
pomodorrior Executable file
View File

@ -0,0 +1,80 @@
#!/bin/sh
# A small Pomodoro's timer for Taskwarrior.
## Vars
TIME=0
# Work on a task (default: 25 min)
WORK_TIME=25
# Take a small break
SHORT_BREAK_TIME=5
# Taskwarrior path
TASKWARRIOR_PATH="${HOME}/.task"
# Current task path
TASK_NAME="${1}"
TASK_PATH="${TASKWARRIOR_PATH}/.current.task"
TASK_ID=$(task description.is:"${TASK_NAME}" ids)
# --------- Dependancies ----------
# Verify Taskwarrior is installed
if ! command -v task > /dev/null; then
printf '%b' "Please install Taskwarrior.\n"
exit 1
fi
# Verify Taskwarrior is initialized
if [ ! -d "${TASKWARRIOR_PATH}" ]; then
printf '%b' "Please initialize Taskwarrior.\n"
exit 1
fi
# ------------- START -------------
# If the task doesn't already exists
if [ ! "${TASK_ID}" ]; then
printf '%b' "${TASK_NAME} don't exist, create it.\n"
fi
## Working on the task
# Start the task
command task start "${TASK_ID}"
printf '%b' "${TASK_NAME} started.\n"
printf '%b' "${TASK_NAME}\n${TIME}" > "${TASK_PATH}"
# Tiny timer for ${WORK_TIME} minutes
while [ "${TIME}" != "${WORK_TIME}" ]; do
sleep 60
TIME=$((TIME+1))
printf '%b' "${TASK_NAME}\n${TIME}" > "${TASK_PATH}"
done
# Stop the task
command task stop "${TASK_ID}"
printf '%b' "${TASK_NAME} stopped.\n"
## Break time
# Toggle the sound
amixer -q set Master toggle
BREAK_MSG="Pause"
BREAK_TIME="${SHORT_BREAK_TIME}"
printf '%b' "${BREAK_MSG}\n${BREAK_TIME}" > "${TASK_PATH}"
while [ "${BREAK_TIME}" -gt 0 ]; do
sleep 60
BREAK_TIME=$((BREAK_TIME-1))
printf '%b' "${BREAK_MSG}\n${BREAK_TIME}" > "${TASK_PATH}"
done
# Toggle the sound
amixer -q set Master toggle
# Delete the task file
rm -f "${TASK_PATH}"
exit 0