bin/b: handle audio better in non-kitty terminal

This commit is contained in:
xeruf 2022-02-10 16:01:25 +01:00
parent e8eeb04303
commit 68ef1c1bcb
1 changed files with 4 additions and 2 deletions

View File

@ -86,13 +86,15 @@ for arg; do
case "$(file "$arg")" in case "$(file "$arg")" in
(*\ ?udio*) (*\ ?udio*)
img="$tmpfile.png" img="$tmpfile.png"
case $TERM in (*-kitty) kitty=true; audioheight=2;; (*) audioheight=5;; esac
if which audiowaveform 2>/dev/null >&2 if which audiowaveform 2>/dev/null >&2
then find "$img" -not -empty 2>/dev/null | grep --quiet . || then find "$img" -not -empty 2>/dev/null | grep --quiet . ||
audiowaveform --quiet --pixels-per-second 2 --height 36 --width 2000 --amplitude-scale auto \ audiowaveform --quiet --pixels-per-second 2 --height 36 --width 2000 --amplitude-scale auto \
--background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \ --background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \
--input-filename "$arg" --output-format png >"$img" && { --input-filename "$arg" --output-format png >"$img" && {
timg -g $(tput cols)x2 "$arg" && printf "\\033[2A " test "$kitty" && timg -g x$audioheight "$arg" &&
timg -g $(tput cols)x2 --auto-crop --upscale "$img" printf "\\033[${audioheight}A%$(expr $audioheight \* 3)s"
timg -g x$audioheight --auto-crop --upscale "$img"
} }
fi fi
timga+=("$arg") timga+=("$arg")