vtv-player - vtv-tools - virtual terminal video tools
 (HTM) git clone git://bitreich.org/vtv-tools  git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/vtv-tools
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
       vtv-player (674B)
       ---
            1 #!/bin/sh
            2 #
            3 # Play a single vtv file in an infinite loop.
            4 #
            5 # Copyright 2023 Troels Henriksen <athas@sigkill.dk>
            6 #
            7 # See LICENSE file for licensing information.
            8 
            9 trap 'clear; tput reset; exit 0' SIGINT
           10 
           11 fps=20
           12 
           13 if [ "$1" = "-r" ]; then
           14     fps=$2
           15     shift; shift;
           16 fi
           17 
           18 if [ $# -ne 1 ]; then
           19     echo "Usage: $0 FILE" >&2
           20     exit 1
           21 fi
           22 
           23 vtv="$1"
           24 frametime=$(echo "scale =2; 1 / $fps" | bc)
           25 framelines=25
           26 
           27 tput civis
           28 clear
           29 i=0
           30 nframes=$(echo "$(wc -l < "${vtv}")" / "$framelines" | bc)
           31 while true; do
           32     tput cup 0 0
           33     tail -n +$(echo "(1+${i} % ${nframes} * ${framelines})" | bc) "$vtv" | head -n $framelines
           34     i=$(($i + 1))
           35 
           36     userinput=""
           37     sleep $frametime
           38 done
           39