#!/bin/bash
audio="/home/anon/Musica/Clasica/Dvorak - New World Symphony (Full).mp3"
work_time=25;
rest_time=5;
long_rest_time=15;
long_rest_interval=5;

alarm() {
    mplayer "$audio"
}

timer () {
    time=$(( $1 * 60 ))
    for i in $(seq 1 $time); do

        total_seconds_remaining=$((time - i))
        minutes_remaining=$((total_seconds_remaining / 60))
        seconds_remaining=$((total_seconds_remaining % 60))

        echo -ne " $minutes_remaining minutos $seconds_remaining segundos restantes...\r"

        sleep 1s
    done
}

display_title() {
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo "| - P - O - M - O - D - O - R - O - |"
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
}

display_session () {
    notify-send "$1"
    echo ""
    echo " $1"
    echo ""
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo ""
}

main () {
    rest_counter=0;
    long_rest_counter=0;
    work_counter=0;

    clear;

    display_title

    while true; do
        ((rest_counter++));
        is_rest_time=$((rest_counter % 2))

        if [ $is_rest_time -eq 0 ] ; then
            ((long_rest_counter++));
            is_long_rest_time=$((long_rest_counter % long_rest_interval))

            if [ $is_long_rest_time -eq 0 ] ; then
                display_session "Sesión de descanso largo — 15 minutos"
                timer $long_rest_time
                alarm
            else
                display_session "Sesión de descanso corto — 5 minutos"
                timer $rest_time
                alarm
            fi
        else
            display_session "Sesión de trabajo — 25 minutos"
            ((work_counter++));
            timer $work_time;
            alarm
        fi

        clear

        total_work_minutes=$((work_counter * work_time))
        work_hours=$((total_work_minutes / 60))
        work_minutes=$((total_work_minutes % 60))

        display_title
        echo ""
        echo -e " Sesiones de trabajo totales: $work_counter";
        echo -e " Tiempo trabajado: $work_hours horas y $work_minutes minutos";
        echo ""
        echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

    done
}

main "$@"

# Copyright (C) 2025 HURSZ
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
Edit

Pub: 21 Aug 2026 00:25 UTC

Views: 17