diff options
author | Yaroslav <contact@yaroslavps.com> | 2019-09-23 06:32:38 +0300 |
---|---|---|
committer | Yaroslav <contact@yaroslavps.com> | 2019-09-23 06:32:38 +0300 |
commit | 93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1 (patch) | |
tree | f5cab1472bf7d95aa72c43a713e104d2827b37a5 /dotfiles/.config/vifm/scripts/imgt | |
download | swayrice-93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1.tar.gz swayrice-93d2743e3864e9eab0699b1bb1ea5f01c10bdbc1.zip |
initial commit
Diffstat (limited to 'dotfiles/.config/vifm/scripts/imgt')
-rwxr-xr-x | dotfiles/.config/vifm/scripts/imgt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/dotfiles/.config/vifm/scripts/imgt b/dotfiles/.config/vifm/scripts/imgt new file mode 100755 index 0000000..5d76d5d --- /dev/null +++ b/dotfiles/.config/vifm/scripts/imgt @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Based on script by z3bra -- 2014-01-21 + +W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" +FONTH=16 # Size of one terminal row +FONTW=9 # Size of one terminal column + +X=$1 +Y=$2 +COLUMNS=$3 +LINES=$4 +FILENAME=$5 + +read width height <<< `echo "5;$FILENAME" | $W3MIMGDISPLAY` +if [ -z "$width" -o -z "$height" ]; then + echo 'Error: Failed to obtain image size.' + exit 1 +fi + +x=$((FONTW * X)) +y=$((FONTH * Y)) + +max_width=$((FONTW * COLUMNS)) +max_height=$((FONTH * LINES)) + +if [ "$width" -gt "$max_width" ]; then + height=$((height * max_width / width)) + width=$max_width +fi +if [ "$height" -gt "$max_height" ]; then + width=$((width * max_height / height)) + height=$max_height +fi + +w3m_command="0;1;$x;$y;$width;$height;;;;;$FILENAME\n4;\n3;" + +echo -e "$w3m_command" | $W3MIMGDISPLAY |