From 83232684a85312c4010bd4f2ad83e797274ce257 Mon Sep 17 00:00:00 2001 From: Lucas Summers Date: Mon, 8 Feb 2021 18:16:28 -0800 Subject: [PATCH 1/2] integrated ueberzug into plugins/preview-tui --- plugins/preview-tui | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/preview-tui b/plugins/preview-tui index a24ac413..0010340e 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -17,7 +17,7 @@ # - tar # - man # - optional: bat for code syntax highlighting -# - optional: kitty terminal or catimg for images +# - optional: kitty terminal, catimg, viu, or ueberzug for images # - optional: scope.sh file viewer from ranger. # To use: # 1. drop scope.sh executable in $PATH @@ -171,6 +171,8 @@ preview_file () { catimg "$1" elif exists viu; then viu -t "$1" + elif exists ueberzug; then + preview_ueberzug "$1" else fifo_pager print_bin_info "$1" fi @@ -193,6 +195,15 @@ preview_file () { fi } +preview_ueberzug() { + height=$(tput lines) + width=$(tput cols) + ueberzug layer --parser json 0< <( + printf '{"action": "add", "identifier": "nnn_ueberzug", "x": 0, "y": 0, "max_width": "%s", "max_height": "%s", "path": "%s"}\n' "$width" "$height" "$1" + read + ) +} + if [ "$PREVIEW_MODE" ] ; then if [ ! -r "$NNN_FIFO" ] ; then echo "No FIFO available! (\$NNN_FIFO='$NNN_FIFO')" >&2 From 8a12c01da41dcc238692c83bd393ebd42be9a9e4 Mon Sep 17 00:00:00 2001 From: Lucas Summers Date: Tue, 9 Feb 2021 10:32:32 -0800 Subject: [PATCH 2/2] fixed shellcheck errors for plugins/preview-tui --- plugins/preview-tui | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/preview-tui b/plugins/preview-tui index 0010340e..b260986b 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -172,7 +172,7 @@ preview_file () { elif exists viu; then viu -t "$1" elif exists ueberzug; then - preview_ueberzug "$1" + preview_ueberzug "$cols" "$lines" "$1" else fifo_pager print_bin_info "$1" fi @@ -196,12 +196,10 @@ preview_file () { } preview_ueberzug() { - height=$(tput lines) - width=$(tput cols) - ueberzug layer --parser json 0< <( - printf '{"action": "add", "identifier": "nnn_ueberzug", "x": 0, "y": 0, "max_width": "%s", "max_height": "%s", "path": "%s"}\n' "$width" "$height" "$1" - read - ) + { + printf '{"action": "add", "identifier": "nnn_ueberzug", "x": 0, "y": 0, "width": "%s", "height": "%s", "path": "%s"}\n' "$1" "$2" "$3" + read -r + } | ueberzug layer --parser json } if [ "$PREVIEW_MODE" ] ; then