No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imgt 800B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. #
  3. # z3bra -- 2014-01-21
  4. test -z "$1" && exit
  5. W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay"
  6. FILENAME=$1
  7. FONTH=14 # Size of one terminal row
  8. FONTW=8 # Size of one terminal column
  9. BORDER=20
  10. COLUMNS=`tput cols`
  11. LINES=`tput lines`
  12. read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY`
  13. offx=$(($BORDER / $FONTH))
  14. offy=$(($BORDER / $FONTW))
  15. max_width=$(($FONTW * $COLUMNS))
  16. max_height=$(($FONTH * $LINES))
  17. if test $width -gt $max_width; then
  18. height=$(($height * $max_width / $width))
  19. width=$max_width
  20. fi
  21. if test $height -gt $max_height; then
  22. width=$(($width * $max_height / $height))
  23. height=$max_height
  24. fi
  25. w3m_command="0;1;$offx;$offy;$width;$height;;;;;$FILENAME\n4;\n3;"
  26. clear
  27. tput cup $(($height/$FONTH)) 0
  28. echo -e $w3m_command|$W3MIMGDISPLAY
  29. read -n1 -s
  30. clear