summaryrefslogtreecommitdiff
path: root/src/slideshow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/slideshow.c')
-rw-r--r--src/slideshow.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/slideshow.c b/src/slideshow.c
index 42aaf2e..189357d 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -381,6 +381,29 @@ void feh_action_run(feh_file * file, char *action)
return;
}
+char *shell_escape(char *input)
+{
+ static char ret[1024];
+ unsigned int out = 0, in = 0;
+
+ ret[out++] = '\'';
+ for (in = 0; input[in] && (out < (sizeof(ret) - 7)); in++) {
+ if (input[in] == '\'') {
+ ret[out++] = '\'';
+ ret[out++] = '"';
+ ret[out++] = '\'';
+ ret[out++] = '"';
+ ret[out++] = '\'';
+ }
+ else
+ ret[out++] = input[in];
+ }
+ ret[out++] = '\'';
+ ret[out++] = '\0';
+
+ return ret;
+}
+
char *feh_printf(char *str, feh_file * file)
{
char *c;
@@ -397,10 +420,18 @@ char *feh_printf(char *str, feh_file * file)
if (file)
strcat(ret, file->filename);
break;
+ case 'F':
+ if (file)
+ strcat(ret, shell_escape(file->filename));
+ break;
case 'n':
if (file)
strcat(ret, file->name);
break;
+ case 'N':
+ if (file)
+ strcat(ret, shell_escape(file->name));
+ break;
case 'w':
if (file && (file->info || !feh_file_info_load(file, NULL))) {
snprintf(buf, sizeof(buf), "%d", file->info->width);