Created
January 25, 2023 23:42
-
-
Save yebt/60fe2db0f9c4d729ef131feeb2d5ffcc to your computer and use it in GitHub Desktop.
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 | |
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