diff options
| author | Robert Günzler <r@gnzler.io> | 2021-02-22 14:10:38 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-04-26 02:09:44 +0200 |
| commit | 1219b3ed31221da86dd12fbbe7b1397ce7bc5c95 (patch) | |
| tree | c864300573bd305c7b775cbf34da9988e629b141 /.config/vifm/scripts/vifm-show-sixel | |
| parent | 00adb97bd818f204c076a63ed9ac4592b080d662 (diff) | |
vifm: colorscheme + sixel script
Diffstat (limited to '.config/vifm/scripts/vifm-show-sixel')
| -rwxr-xr-x | .config/vifm/scripts/vifm-show-sixel | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/vifm/scripts/vifm-show-sixel b/.config/vifm/scripts/vifm-show-sixel new file mode 100755 index 0000000..1644153 --- /dev/null +++ b/.config/vifm/scripts/vifm-show-sixel @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +if [ "$#" -ne 3 ]; then + echo "Usage: $0 filename width height" + exit 1 +fi + +dim=( $(convert "$1" -format "%w %h" info:) ) +w=${dim[0]} +h=${dim[1]} + +pw=$(($2*8)) +ph=$(($3*14)) + +height=auto +width=auto +if [ $pw -lt $w ] && [ $ph -lt $h ]; then + newh=$(echo "($h*$pw)/$w" | bc) + neww=$(echo "($w*$ph)/$h" | bc) + + if [ $newh -le $ph ]; then + width=$pw + else + height=$ph + fi +elif [ $pw -lt $w ]; then + width=$pw +elif [ $ph -lt $h ]; then + height=$ph +fi + +# debugging stuff +# echo pw=$pw ph=$ph +# echo w=$w h=$h +# echo neww=$neww newh=$newh +# exec echo width=$width height=$height + +# account for GNU screen +if [ -n "$STY" ]; then + popt=-P +fi + +exec img2sixel $popt --width=$width --height=$height "$1" |