#! /bin/zsh # # this file: # https://dataswamp.org/~incal/conf/.zsh/stretch # # new version: # https://dataswamp.org/~incal/conf/.zsh/audio-timer random-video () { local vid_dir=${1:-.} local ext=${2:-mkv} local vids=("${(@f)$(ls ${vid_dir}/*.${ext})}") local num_vids=${#vids} local vid_num=$(( RANDOM % $num_vids + 1 )) local vid=$vids[$vid_num] echo $vid } alias rv=random-video play-stretch-sound () { local sound=~/bo/up.mp3 if [[ -f $sound ]]; then omx-play-whatever $OMX_SND_MOD $sound else echo "Error: Can't find sound file: $sound" >&2 fi } STRETCH_TIME=65 stretch-get-human-time-string () { local stretches=$1 local total_time=$(( $stretches * $STRETCH_TIME )) local human_time="$(s2hms ${total_time})" echo $human_time } alias hst=stretch-get-human-time-string alias sth=stretch-get-human-time-string stretch () { local init_time=10 local stretches=73 echo "Max time: $(stretch-get-human-time-string $stretches)" local current=0 sleep $init_time echo -n "current:" repeat $stretches { current=$(( $current + 1 )) echo -n " $current" play-stretch-sound sleep $STRETCH_TIME } repeat 2 play-stretch-sound } alias st=stretch