File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ title : " Script series 4"
3+ date : 2025-11-25
4+ categories :
5+ - Scripts
6+ tags :
7+ - Scripts
8+ - tools
9+ - linux
10+ - posix
11+ ---
12+
13+ Ello
14+
15+ Today's script is a pomodoro timer which uses festival to use TTS to get you to stop working or start working again
16+
17+ This first part is to format time for the timer
18+ ``` bash
19+ function format_time() {
20+ local seconds=$1
21+ printf " %02d:%02d:%02d" $(( seconds / 3600 )) $(( (seconds % 3600 ) / 60 )) $(( seconds % 60 ))
22+ }
23+ ```
24+
25+
26+ This function starts with setting work time and break time
27+ and then for each cycle it sends a notification and TTS message
28+ ``` bash
29+ function pomodoro_timer() {
30+ local work_time=" 30 * 60" # 25 minutes in seconds
31+ local break_time=" 10 * 60" # 5 minutes in seconds
32+ local cycles=3 # Number of Pomodoro cycles
33+
34+ for (( cycle = 1 ; cycle <= cycles; cycle++ )) ; do
35+ for (( time_left = work_time; time_left > 0 ; time_left-- )) ; do
36+ echo -ne " Pomodoro $cycle : Work Time Left: $( format_time $time_left ) \033[0K\r"
37+ sleep 1
38+ done
39+
40+ echo " Time for a short break!" | festival --tts # Notify using Festival
41+ notify-send " Pomodoro $cycle " " Time for a short break!" -t 5000 # Notify using notify-send
42+
43+ for (( time_left = break_time; time_left > 0 ; time_left-- )) ; do
44+ echo -ne " Pomodoro $cycle : Break Time Left: $( format_time $time_left ) \033[0K\r"
45+ sleep 1
46+ done
47+
48+ echo " Back to work!" | festival --tts # Notify using Festival
49+ notify-send " Pomodoro $cycle " " Back to work!" -t 5000 # Notify using notify-send
50+
51+ done
52+ echo -ne " \033[0K\r"
53+ echo " Pomodoro completed!"
54+ }
55+ ```
You can’t perform that action at this time.
0 commit comments