zsh-users
 help / 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; 1+ messages 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] 1+ messages in thread

only message in thread, back to index

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

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox