Last active
October 10, 2023 06:46
-
-
Save emelent/8aec65faf551fd0edd32dcf6fbc485c7 to your computer and use it in GitHub Desktop.
Simple bash function to use pomodoro method with task-warrior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pomo_minutes=5 | |
# I have a task that I never complete made which I use to track pomodoro breaks | |
# so, set one up yourself, get it's uuid and place that here | |
pomo_task_uuid=<pomodoro-task-uuid> | |
function pomo { | |
task_id=$1 | |
minutes=25 | |
[ $# -gt 1 ] && minutes=$2 | |
trap "echo; task stop $task_id; return 1;" INT | |
end_time=`python3 -c "from datetime import datetime as d, timedelta as t;print((d.now() + t(minutes=$minutes)).strftime('%H:%M'))"` || | |
(echo "Python3 required to use this script." && return 1) | |
pomo_end_time=`python3 -c "from datetime import datetime as d, timedelta as t;print((d.now() + t(minutes=$pomo_minutes)).strftime('%H:%M'))"` | |
task_name=`task _get $task_id.description` || | |
(echo "Taskwarrior required to use this script." && return 1) | |
task start $task_id || | |
(echo "Failed to start task $task_id" && return 2) | |
echo "\nFinishing at $end_time" | |
echo "---------------------------\n\n" | |
echo "Press Ctrl-C to cancel" | |
sleep `expr 60 \* $minutes` || | |
(echo "Failed to run sleep command" && return 2) | |
task stop $task_id | |
echo "\nPomodoro complete" | |
for i in {1..3} | |
do | |
# use whatever command you like to play audio file on your system | |
afplay /System/Library/Sounds/Submarine.aiff || | |
echo "Failed to play sound" | |
done | |
task start $pomo_task_uuid || | |
(echo "Failed to start pomodoro task $task_id" && return 2) | |
echo "$pomodor_minutes break ending at $pomo_end_time" | |
echo "---------------------------\n\n" | |
echo "Press Ctrl-C to cancel" | |
sleep `expr 60 \* $pomo_minutes` | |
(echo "Failed to run sleep command" && return 2) | |
for i in {1..3} | |
do | |
# use whatever command you like to play audio file on your system | |
afplay /System/Library/Sounds/Submarine.aiff || | |
echo "Failed to play sound" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment