From 68ef1c1bcb00b466fde502130ecd6c5a9ce172f2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 10 Feb 2022 16:01:25 +0100 Subject: [PATCH] bin/b: handle audio better in non-kitty terminal --- .local/bin/scripts/b | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 346f8cf..b8ac2f5 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -86,13 +86,15 @@ for arg; do case "$(file "$arg")" in (*\ ?udio*) img="$tmpfile.png" + case $TERM in (*-kitty) kitty=true; audioheight=2;; (*) audioheight=5;; esac if which audiowaveform 2>/dev/null >&2 then find "$img" -not -empty 2>/dev/null | grep --quiet . || audiowaveform --quiet --pixels-per-second 2 --height 36 --width 2000 --amplitude-scale auto \ --background-color 000000 --waveform-color 99BBFF --axis-label-color 000000 \ --input-filename "$arg" --output-format png >"$img" && { - timg -g $(tput cols)x2 "$arg" && printf "\\033[2A " - timg -g $(tput cols)x2 --auto-crop --upscale "$img" + test "$kitty" && timg -g x$audioheight "$arg" && + printf "\\033[${audioheight}A%$(expr $audioheight \* 3)s" + timg -g x$audioheight --auto-crop --upscale "$img" } fi timga+=("$arg")