#!/bin/sh TITLE="Tomatimer!" ICON1="$HOME/img/.icn/tomate1.png" ICON2="$HOME/img/.icn/tomate2.png" BEEP="paplay ~/snd/.notification.ogg" uso() { echo "Uso: $(basename "$0") [focus time] [short break] [long break]" } if [ "$1" = "-h" ]; then uso exit 0 fi focus_time=${1:-25} short_break=${2:-5} long_break=${3:-20} # Ensure all arguments are numbers case $focus_time$short_break$long_break in *[!0-9]*) echo "Todos los argumentos deben ser números enteros positivos" >&2 usage >&2 exit 1 ;; esac countdown() { timer=$(($1 * 60)) while true; do # minutos=$((timer / 60)) # segundos=$((timer - 60*minutes)) # printf '\e[0K\r' # printf 'Quedan: %02d:%02d' "$minutos" "$segundos" [ $timer -eq 0 ] && break timer=$((timer - 1)) sleep 1 done # printf '\n' } while true; do notify-send "$TITLE" --icon="$ICON2" "Concentrate por $focus_time minutos" countdown "$focus_time" notify-send "$TITLE" --icon="$ICON1" "Hace una pausa de $short_break minutos (1/4)" && $BEEP countdown "$short_break" notify-send "$TITLE" --icon="$ICON2" "Concentrate por $focus_time minutos" countdown "$focus_time" notify-send "$TITLE" --icon="$ICON1" "Hace una pausa de $short_break minutos (2/4)" && $BEEP countdown "$short_break" notify-send "$TITLE" --icon="$ICON2" "Concentrate por $focus_time minutos" countdown "$focus_time" notify-send "$TITLE" --icon="$ICON1" "Hace una pausa de $short_break minutos (3/4)" && $BEEP countdown "$short_break" notify-send "$TITLE" --icon="$ICON2" "Concentrate por $focus_time minutos" countdown "$focus_time" notify-send "$TITLE" --icon="$ICON1" "Hora del recreo. Salí de la compu por $long_break minutos (4/4)" && $BEEP countdown "$long_break" done