Last active
June 15, 2022 18:37
-
-
Save AnderRasoVazquez/5830829cb73e70c7c5e7 to your computer and use it in GitHub Desktop.
[A simple pomodoro script for Bash shell] #shell #bash
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
#!/bin/bash | |
## pomodoro script by Ander Raso Vázquez [email protected] | |
############## DOCUMENTATION ################### | |
## After a pomodoro of 25 min -> 5 min break | |
## After 4 pomodoros done -> 15 min break | |
## | |
## USAGE | |
## [command] [number of pomodoros] | |
## example: | |
## $ ./pomodoro.sh 5 | |
################################################ | |
echo "#### Pomodoro Counter ####" | |
if [[ -n "$1" ]]; then | |
pomodoros_need=$1 | |
else | |
read -p "How much pomodoros do you need? " pomodoros_need | |
fi | |
# 4 cicles of pomodoros = long break | |
pomodoro_cicle=0 | |
for (( c=1; c<=$pomodoros_need; c++ )) # c = pomodoro count | |
do | |
pomodoro_cicle=$(($pomodoro_cicle+1)) | |
echo "Time for Pomodoro #$c, work!" | |
notify-send "Pomodoro Counter" "Time for Pomodoro #$c, work!" | |
sleep 1500 # 25 min work | |
if [[ "$pomodoro_cicle" = 4 ]]; then | |
echo "#$c pomodoro done, it's long break time!" | |
notify-send "Pomodoro Counter" "#$c pomodoro done, it's long break time!" | |
pomodoro_cicle=0 | |
sleep 900 # long break of 15 min | |
else | |
echo "#$c pomodoro done, it's break time!" | |
notify-send "Pomodoro Counter" "#$c pomodoro done, it's break time!" | |
sleep 300 # short break of 5 min | |
fi | |
echo "Break finished, get back to work!" | |
notify-send "Pomodoro Counter" "Break finished, get back to work!" | |
done | |
echo "No more pomodoros left, did you finish the task?" | |
notify-send "Pomodoro Counter" "No more pomodoros left, did you finish the task?" | |
exit 0 |
Thanks! I'll use it! :)
To make it more radical I'll flip the screen and play a sound, I post it here in case someone is looking something similar
After line 25: sleep 1500 # 25 min work
xrandr -o right
aplay /usr/share/sounds/sound-icons/xylofon.wav
and after line 47: fi
aplay /usr/share/sounds/sound-icons/piano-3.wav
xrandr -o normal
Greetings!
cool!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great work! Some comments: On Ubuntu 16.04
notify-send
doesn't work without-u critical
. Also alternative we could use this alias (need sox package toplay
):