Created
February 8, 2023 12:15
-
-
Save plumpNation/8a45de54dbe4251318fe73c9a2a3d677 to your computer and use it in GitHub Desktop.
Simple bash script to implement a linux pomodoro timer
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 | |
# based on https://gist.github.com/bashbunni/3880e4194e3f800c4c494de286ebc1d7?permalink_comment_id=4445592#gistcomment-4445592 | |
# Requires https://github.com/caarlos0/timer to be installed. | |
# Requires lolcat (should be a simple apt/yum install) | |
# spd-say should ship with your distro | |
declare -A pomo_options | |
pomo_options["work"]="25" | |
pomo_options["break"]="10" | |
pomo_options["short-break"]="5" | |
# pomodoro 5 will do a loop of 5 pomodoro sessions of 25 mins | |
pomodoro() { | |
val=$1 | |
echo $val | lolcat | |
timer ${pomo_options["$val"]}m | |
spd-say "'$val' session done" | |
notify-send --app-name=Pomodoro🍅 "'$val' session done 🍅" | |
} | |
start_pomodoro() { | |
# Number of times to repeat the loop, default is 2 | |
if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then | |
num_loops=$1 | |
else | |
# Default loops | |
num_loops=2 | |
fi | |
for i in $(seq 1 $num_loops); do | |
pomodoro "work" | |
if [ $i -lt $num_loops ]; then | |
pomodoro "short-break" | |
fi | |
done | |
} | |
change_pomo() { | |
if [ -n "$1" ] && [ -n "$2" ]; then | |
pomo_options["$1"]="$2" | |
echo "The $1 time has been changed to $2 minutes" | |
else | |
echo "Please provide valid parameters: change_pomo [work/break] [time_in_minutes]" | |
fi | |
} | |
alias doro=start_pomodoro | |
alias doro-work="pomodoro 'work'" | |
alias doro-break="pomodoro 'break'" | |
alias doro-short-break="pomodoro 'short-break'" | |
alias doro-change=change_pomo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment