Tomato clock!

Just a simple script that reminds you to take some rest every n minutes

optional assets:

  • some nice soundfx
  • a potato logo (here ~/utils/tomato.png)

tomato

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/bash

# default; time in minutes
INTERVAL=40
BREAK=5
function print_help {
    echo "USAGE $0 [opts]"
    echo "options"
    echo "-i/--interval [num] duration of each work cycle, default 40"
    echo "-b/--break [num] duration of a break, default 5"
}

re='^[0-9]+$'
while [[ $# -gt 0 ]]; do
  case $1 in
    -i|--interval)
      if ! [[ $2 =~ $re ]] ; then
        echo "invalid input" >&2; print_help; exit 1
      fi
      INTERVAL="$2"
      shift # past argument
      shift # past value
      ;;
    -b|--break)
      if ! [[ $2 =~ $re ]] ; then
        echo "invalid input" >&2; print_help; exit 1
      fi
      BREAK="$2"
      shift # past argument
      shift # past value
      ;;
    -*|--*)
      print_help
      exit 1
      ;;
    *)
      POSITIONAL_ARGS+=("$1") # save positional arg
      shift # past argument
      ;;
  esac
done

let "SLEEP = $INTERVAL * 60"
let "SLEEPW = $BREAK * 60"
notify-send "timer set! next break in $INTERVAL minutes, break time $BREAK minutes  " --app-name="Tomato Timer" -i ~/utils/tomato.png

sleep $SLEEP

while true
do
    notify-send -u critical "$INTERVAL minutes elapsed, relax!  " --app-name="Tomato Timer" -i ~/utils/tomato.png
    sleep $SLEEPW
    notify-send "timer set! \n next break in $INTERVAL minutes  " --app-name="Tomato Timer" -i ~/utils/tomato.png
    sleep $SLEEP
done
edited 20.04.2024
created 07.10.2023
EOF
[+] click to leave a comment [+]
the comment system on this blog works via email. The button
below will generate a mailto: link based on this page's url 
and invoke your email client - please edit the comment there!

[optional] even better, encrypt the email with my public key

- don't modify the subject field
- specify a nickname, otherwise your comment will be shown as   
  anonymous
- your email address will not be disclosed
- you agree that the comment is to be made public.
- to take down a comment, send the request via email.

>> SEND COMMENT <<