Skip to content

Instantly share code, notes, and snippets.

@AnderRasoVazquez
Last active June 15, 2022 18:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save AnderRasoVazquez/5830829cb73e70c7c5e7 to your computer and use it in GitHub Desktop.
Save AnderRasoVazquez/5830829cb73e70c7c5e7 to your computer and use it in GitHub Desktop.
[A simple pomodoro script for Bash shell] #shell #bash
#!/bin/bash
## pomodoro script by Ander Raso Vázquez anderraso@gmail.com
############## 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
@pabloab
Copy link

pabloab commented Jul 16, 2017

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 to play):

alias pomodoro='sleep 25m && for NUM in `seq 3`; do notify-send -u critical "End of pomodoro"; play -q -n synth 2 pluck E3; done'

@grodrigo
Copy link

grodrigo commented Nov 7, 2021

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!

@sebastiansperandio
Copy link

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment