zsh-users
 help / color / mirror / code / Atom feed
* 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
@ 2019-08-20  6:35 Emanuel Berg
  0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2019-08-20  6:35 UTC (permalink / raw)
  To: zsh-users

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-20  6:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20  6:35 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 Emanuel Berg

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).