summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-04-04 08:35:11 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-04-04 08:35:11 +0200
commit1e212f65c87fd634c738b4c79e1ffed5c29b039d (patch)
tree402dec61cff929013dadbb459c093d5fc1c635e4
parentf8640490308f29de951b7b59f07be8b744f6e895 (diff)
Add %g and %Z format specifiers (closes #391)
-rw-r--r--man/feh.pre13
-rw-r--r--src/slideshow.c12
2 files changed, 23 insertions, 2 deletions
diff --git a/man/feh.pre b/man/feh.pre
index eb31f37..cc67b25 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -1014,6 +1014,10 @@ Image path/filename
Escaped image path/filename
.Pq for use in shell commands
.
+.It %g
+.
+w,h window dimensions in pixels (mnemonic: geometry)
+.
.It %h
.
Image height
@@ -1048,8 +1052,9 @@ Number of image pixels
.
.It \&%P
.
-Number of image pixels
+Number of image pixels in human-readable format with k/M
.Pq kilopixels / megapixels
+suffix
.
.It %r
.
@@ -1087,7 +1092,11 @@ Process ID
.
.It %z
.
-current image zoom
+Current image zoom, rounded to two decimal places
+.
+.It %Z
+.
+Current image zoom, higher precision
.
.It %%
.
diff --git a/src/slideshow.c b/src/slideshow.c
index effdcaf..7bad2c9 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -468,6 +468,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
if (file)
strncat(ret, shell_escape(file->filename), sizeof(ret) - strlen(ret) - 1);
break;
+ case 'g':
+ if (winwid) {
+ snprintf(buf, sizeof(buf), "%d,%d", winwid->w, winwid->h);
+ strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);
+ }
+ break;
case 'h':
if (file && (file->info || !feh_file_info_load(file, NULL))) {
snprintf(buf, sizeof(buf), "%d", file->info->height);
@@ -564,6 +570,12 @@ char *feh_printf(char *str, feh_file * file, winwidget winwid)
strncat(ret, "1.00", sizeof(ret) - strlen(ret) - 1);
}
break;
+ case 'Z':
+ if (winwid) {
+ snprintf(buf, sizeof(buf), "%f", winwid->zoom);
+ strncat(ret, buf, sizeof(ret) - strlen(ret) - 1);
+ }
+ break;
case '%':
strncat(ret, "%", sizeof(ret) - strlen(ret) - 1);
break;