Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

audio-timer, when I sent it I was offline from news.gmane.org so I don't know if you got it, I sure don't see it



Is this any good?

Oh, obviously not everyone has omx-play-sound,
unix-time, and the files are hard-coded but
I think you get the meaning. Feel free to set
it up POSIX style BTW :)

#! /bin/zsh

# this file: http://user.it.uu.se/~embe8573/conf/.zsh/audio-timer
#            https://dataswamp.org/~incal/conf/.zsh/audio-timer

timer () {
    # arguments
    local init=${1:-10}     # seconds
    local interval=${2:-40} # s
    local pause=${3:-0}     # s
    local total=${4:-60}    # minutes

    # stop time
    local total_secs=$(( $total * 60 ))

    local now=$(unix-time)
    local stop_time=$(( $now + $total_secs ))

    # sounds
    local interval_sound=~/bo/blum/blum.mp3
    local pause_sound=~/bo/bo/bo.m4a
    local end_sound=~/bo/up.mp3

    # report
    echo "    init: $init s"
    echo "interval: $interval s"
    echo "   pause: $pause s"
    echo "   total: $total min"

    # get up your chair
    echo "\n(get ready...)"
    sleep $init

    local so_far=1

    # go
    echo "\n[program begins]"

    echo -n "\nso far: "
    while (( $now < $stop_time )); do
        omx-play-sound $interval_sound
        sleep $interval # do stretch/exercise here
        echo -n "$so_far "
        so_far=$(( $so_far + 1 ))

        # pause
        if (( $pause > 0 )); then
            omx-play-sound $pause_sound
            sleep $pause
        fi

        now=$(unix-time)
    done

    # done
    omx-play-sound $end_sound
    echo "\n\ngreat work, you are done! :)"
}


-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal



Messages sorted by: Reverse Date, Date, Thread, Author