From 6bdf2eef44b667298aa8f7bd61aa59e59050f588 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Wed, 3 Oct 2018 00:06:33 +0200 Subject: Use output directory for image saving command. --- man/feh.pre | 2 +- src/slideshow.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/man/feh.pre b/man/feh.pre index f65ccd2..2587501 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -589,7 +589,7 @@ image. . Save files to .Ar directory -.Pq only useful with -k . +.Pq only useful with -k , -o / -O or the save_image command . By default, files are saved in the current working directory. . .It Cm -p , --preload diff --git a/src/slideshow.c b/src/slideshow.c index 3770677..63c0a11 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -615,18 +615,21 @@ void slideshow_save_image(winwidget win) { char *tmpname; Imlib_Load_Error err; + char *base_dir = estrjoin("", opt.output_dir ? opt.output_dir : "", "/", NULL); if (win->file) { - tmpname = feh_unique_filename("", FEH_FILE(win->file->data)->name); + tmpname = feh_unique_filename(base_dir, FEH_FILE(win->file->data)->name); } else if (mode) { char *tmp; tmp = estrjoin(".", mode, "png", NULL); - tmpname = feh_unique_filename("", tmp); + tmpname = feh_unique_filename(base_dir, tmp); free(tmp); } else { - tmpname = feh_unique_filename("", "noname.png"); + tmpname = feh_unique_filename(base_dir, "noname.png"); } + free(base_dir); + if (opt.verbose) fprintf(stderr, "saving image to filename '%s'\n", tmpname); -- cgit v1.2.3 From 310432883fb3712acd31af4570618454e9cdcd59 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 18 Nov 2018 20:14:13 +0100 Subject: feh(1): --output-dir does not affect -o / -O --- man/feh.pre | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/feh.pre b/man/feh.pre index f59d082..173410e 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -594,7 +594,9 @@ image. . Save files to .Ar directory -.Pq only useful with -k , -o / -O or the save_image command . +when using +.Cm --keep-http +or the save_image command. By default, files are saved in the current working directory. . .It Cm -p , --preload -- cgit v1.2.3 From ddf90e154a33a4e15054d962124f381eb3608fa2 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 18 Nov 2018 20:19:49 +0100 Subject: Make slideshow_save_image work again when opt.output_dir is unset --- src/slideshow.c | 9 +++++++-- src/utils.c | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/slideshow.c b/src/slideshow.c index 19aeaee..145bee1 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -615,7 +615,10 @@ void slideshow_save_image(winwidget win) { char *tmpname; Imlib_Load_Error err; - char *base_dir = estrjoin("", opt.output_dir ? opt.output_dir : "", "/", NULL); + char *base_dir = ""; + if (opt.output_dir) { + base_dir = estrjoin("", opt.output_dir, "/", NULL); + } if (win->file) { tmpname = feh_unique_filename(base_dir, FEH_FILE(win->file->data)->name); @@ -628,7 +631,9 @@ void slideshow_save_image(winwidget win) tmpname = feh_unique_filename(base_dir, "noname.png"); } - free(base_dir); + if (opt.output_dir) { + free(base_dir); + } if (opt.verbose) fprintf(stderr, "saving image to filename '%s'\n", tmpname); diff --git a/src/utils.c b/src/utils.c index ec30d4a..087e7f6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -152,6 +152,7 @@ char path_is_url(char *path) { return 0; } +/* Note: path must end with a trailing / or be an empty string */ /* free the result please */ char *feh_unique_filename(char *path, char *basename) { -- cgit v1.2.3