zsh-users
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasenwood@zoho.eu>
To: zsh-users@zsh.org
Subject: 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
Date: Tue, 20 Aug 2019 08:35:55 +0200	[thread overview]
Message-ID: <86lfvoe438.fsf@zoho.eu> (raw)

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


                 reply	other threads:[~2019-08-20  6:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86lfvoe438.fsf@zoho.eu \
    --to=moasenwood@zoho.eu \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).