Krolyxon
Commit aabc2bd

Branches

Refs →

nsxivaabc2bd

Provide image width and height to image-info script; fixes issue #159

Author
Bert Münnich
Date
2016-08-06 12:22 +0200
Parent
f32771a
Commit
aabc2bddbdeecdb2651394d90b10a9290a69b527

+12 −5

3 files changed

  1. M exec/image-info +6 −3
  2. M main.c +4 −1
  3. M sxiv.1 +2 −1
M exec/image-info View
@@ -1,16 +1,19 @@
11 #!/bin/sh
22
33 # Example for $XDG_CONFIG_HOME/sxiv/exec/image-info
4−# Called by sxiv(1) whenever an image gets loaded,
5−# with the name of the image file as its first argument.
4+# Called by sxiv(1) whenever an image gets loaded.
65 # The output is displayed in sxiv's status bar.
6+# Arguments:
7+# $1: path to image file
8+# $2: image width
9+# $3: image height
710
811 s=" | " # field separator
912
1013 filename=$(basename -- "$1")
1114 filesize=$(du -Hh -- "$1" | cut -f 1)
1215
13−geometry=$(identify -format '%wx%h' ":$1[0]")
16+geometry="${2}x${3}"
1417 tags=$(identify -format '%[IPTC:2:25]' ":$1" | tr ';' ',')
1518
1619 echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"
M main.c View
@@ -224,6 +224,7 @@ void open_info(void)
224224 {
225225 static pid_t pid;
226226 int pfd[2];
227+ char w[12], h[12];
227228
228229 if (info.f.err != 0 || info.open || win.bar.h == 0)
229230 return;
@@ -239,7 +240,9 @@ void open_info(void)
239240 if ((pid = fork()) == 0) {
240241 close(pfd[0]);
241242 dup2(pfd[1], 1);
242− execl(info.f.cmd, info.f.cmd, files[fileidx].name, NULL);
243+ snprintf(w, sizeof(w), "%d", img.w);
244+ snprintf(h, sizeof(h), "%d", img.h);
245+ execl(info.f.cmd, info.f.cmd, files[fileidx].name, w, h, NULL);
243246 error(EXIT_FAILURE, errno, "exec: %s", info.f.cmd);
244247 }
245248 close(pfd[1]);
M sxiv.1 View
@@ -366,7 +366,8 @@ The information displayed on the left side of the status bar can be replaced
366366 with the output of a user-provided script, which is called by sxiv whenever an
367367 image gets loaded. The path of this script is
368368 .I $XDG_CONFIG_HOME/sxiv/exec/image-info
369−and the first argument to this script is the path of the loaded image.
369+and the arguments given to it are: 1) path to image file, 2) image width,
370+3) image height.
370371 .P
371372 There is also an example script installed together with sxiv as
372373 .IR PREFIX/share/sxiv/exec/image-info .