summaryrefslogtreecommitdiff
path: root/src/slideshow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/slideshow.c')
-rw-r--r--src/slideshow.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/slideshow.c b/src/slideshow.c
index 189357d..a65d95e 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -404,6 +404,19 @@ char *shell_escape(char *input)
return ret;
}
+char *format_size(int size)
+{
+ static char ret[5];
+ char units[] = {' ', 'k', 'M', 'G', 'T'};
+ unsigned char postfix = 0;
+ while (size >= 1000) {
+ size /= 1000;
+ postfix++;
+ }
+ snprintf(ret, 5, "%3d%c", size, units[postfix]);
+ return ret;
+}
+
char *feh_printf(char *str, feh_file * file)
{
char *c;
@@ -452,9 +465,7 @@ char *feh_printf(char *str, feh_file * file)
break;
case 'S':
if (file && (file->info || !feh_file_info_load(file, NULL))) {
- snprintf(buf, sizeof(buf),
- "%.2fkB", ((double)file->info->size / 1000));
- strcat(ret, buf);
+ strcat(ret, format_size(file->info->size));
}
break;
case 'p':
@@ -463,14 +474,16 @@ char *feh_printf(char *str, feh_file * file)
strcat(ret, buf);
}
break;
+ case 'P':
+ if (file && (file->info || !feh_file_info_load(file, NULL))) {
+ strcat(ret, format_size(file->info->pixels));
+ }
+ break;
case 't':
if (file && (file->info || !feh_file_info_load(file, NULL))) {
strcat(ret, file->info->format);
}
break;
- case 'P':
- strcat(ret, PACKAGE);
- break;
case 'v':
strcat(ret, VERSION);
break;