summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAlex Voloshyn <a.voloshyn@gmail.com>2019-05-20 13:48:14 +0900
committerAlex Voloshyn <a.voloshyn@gmail.com>2019-05-20 13:48:14 +0900
commitf807448b649f382a73d60cce4a6d0dcffce7decc (patch)
treefb4571c5734524ff5273be81dfba4094e1822f53 /bin
parent27655714ef340a0df6a1e177c7f28f2cc887fa84 (diff)
use image resolution instead of window row/col size to display the image attachment
Diffstat (limited to 'bin')
-rwxr-xr-xbin/muttimage12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/muttimage b/bin/muttimage
index 03bd5f3..c798293 100755
--- a/bin/muttimage
+++ b/bin/muttimage
@@ -1,5 +1,11 @@
#!/bin/bash
-height=$(stty size | awk 'BEGIN {FS = " "} {print $1;}')
-width=$(stty size | awk 'BEGIN {FS = " "} {print $2;}')
+
+#get image resolution
+resolution=$(identify $1 | awk '{print $3}')
+IFS='x' # x is set as delimiter
+read -ra ADDR <<< "$resolution"
+width=${ADDR[0]}
+height=${ADDR[1]}
+
### Display Image / offset with mutt bar
-echo -e "2;3;\n0;1;210;20;$((width*7-250));$((height*14-100));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay &
+echo -e "2;3;\n0;1;0;42;$((width));$((height));0;0;0;0;$1\n4;\n3;" | /usr/lib/w3m/w3mimgdisplay &