Skip to content

Instantly share code, notes, and snippets.

@yebt
Created January 25, 2023 23:42
Show Gist options
  • Save yebt/60fe2db0f9c4d729ef131feeb2d5ffcc to your computer and use it in GitHub Desktop.
Save yebt/60fe2db0f9c4d729ef131feeb2d5ffcc to your computer and use it in GitHub Desktop.
#!/bin/bash
PMDR_WRK="25"
PMDR_BRK="5"
PMDR_LBRK="15"
# check command
if ! command -v lolcat &>/dev/null; then
echo "'lolcat' could not be found https://github.com/busyloop/lolcat"
exit
fi
if ! command -v timer &>/dev/null; then
echo "'timer' could not be found https://github.com/caarlos0/timer"
exit
fi
usage() {
echo -e "USAGE:
$(basename $0) [-c [<numer>]] [TYPE_TIMER]
-c [<N>] Execute N cycles in pomodoro
-d Run default pomodoro cicle w,b,w,b,w,b,w,l
TYPE_TIMER: is a string
-h: Help
-w: Work time
-b: Break time
-l: Long break time"
}
[[ -z "$1" ]] && usage && exit 1
declare -A pomo_options
pomo_options["work"]=$PMDR_WRK
pomo_options["break"]=$PMDR_BRK
pomo_options["long_break"]=$PMDR_LBRK
pomodoro() {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1
time=${pomo_options["$val"]}s
echo -e Now to $val - for $time $2 | lolcat
# timer ${pomo_options["$val"]}m
timer -n pomodoro-$1 $time && notify-send "'$val' session done!!" --icon=dialog-information || exit 1
fi
}
cpomodoro() {
pomodoro "work" "[πŸ’»]"
echo ""
pomodoro "break" "[πŸƒ]"
echo ""
pomodoro "work" "[πŸ’»]"
echo ""
pomodoro "break" "[πŸƒ]"
echo ""
pomodoro "work" "[πŸ’»]"
echo ""
pomodoro "break" "[πŸƒ]"
echo ""
pomodoro "work" "[πŸ’»]"
echo ""
pomodoro "long break" "[β˜•]"
}
while getopts ":wbldc:" flag; do
case "${flag}" in
c)
echo "colro"
i=0
lim=${OPTARG}
while [ $i -le $lim ]; do
echo -e "#### Initialize Pomodoro Cycle No $(($i+1))/$lim\n" | lolcat
cpomodoro
i=$(($i + 1))
done
break # break if use the cycle state
;;
d)
cpomodoro
break # break if use the cycle state
;;
w)
pomodoro "work" "[πŸ’»]"
;;
b)
pomodoro "break" "[πŸƒ]"
;;
l)
pomodoro "long_break" "[β˜•]"
;;
*)
usage
exit 1
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment