From 310d50759ca8c7c34f12c58b07f912805a064397 Mon Sep 17 00:00:00 2001 From: Ignacio Losiggio Date: Thu, 23 Jan 2020 21:35:14 -0300 Subject: Ignore --start-at if the parameter is an URL --- src/options.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/options.c b/src/options.c index d3c1d52..aae10c2 100644 --- a/src/options.c +++ b/src/options.c @@ -843,7 +843,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) } } else if (finalrun && !opt.filelistfile && !opt.bgmode) { - if (opt.start_list_at && !path_is_url(opt.start_list_at) && strrchr(opt.start_list_at, '/')) { + if (opt.start_list_at && path_is_url(opt.start_list_at)) { + add_file_to_filelist_recursively(opt.start_list_at, FILELIST_FIRST); + } else if (opt.start_list_at && strrchr(opt.start_list_at, '/')) { char *target_directory = estrdup(opt.start_list_at); char *filename_start = strrchr(target_directory, '/'); if (filename_start) { -- cgit v1.2.3 From 073e94cd65c69146c195d09bfb196142ca8ec157 Mon Sep 17 00:00:00 2001 From: Ignacio Losiggio Date: Thu, 23 Jan 2020 21:45:15 -0300 Subject: Change local-files for general uris in feh.desktop --- share/applications/feh.pre | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/applications/feh.pre b/share/applications/feh.pre index e5efc5b..5f7a495 100644 --- a/share/applications/feh.pre +++ b/share/applications/feh.pre @@ -4,7 +4,7 @@ Name[en_US]=feh GenericName=Image viewer GenericName[en_US]=Image viewer Comment=Image viewer and cataloguer -Exec=feh --start-at %f +Exec=feh --start-at %u Terminal=false Type=Application Icon=feh -- cgit v1.2.3 From 74e999d523a5022b1489e1870a5b3bde0597cde4 Mon Sep 17 00:00:00 2001 From: GreenLunar Date: Thu, 26 Mar 2020 12:30:35 +0200 Subject: Add WebP image format --- share/applications/feh.pre | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/applications/feh.pre b/share/applications/feh.pre index e5efc5b..9b617e0 100644 --- a/share/applications/feh.pre +++ b/share/applications/feh.pre @@ -9,5 +9,5 @@ Terminal=false Type=Application Icon=feh Categories=Graphics;2DGraphics;Viewer; -MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-tga;image/x-xbitmap; +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/webp;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-tga;image/x-xbitmap; NoDisplay=true -- cgit v1.2.3 From b89cf18dab68008de86d7461e800aae5e9d515b0 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 29 Mar 2020 07:54:57 +0200 Subject: Document --start-at adjustments --- man/feh.pre | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man/feh.pre b/man/feh.pre index f019811..e098672 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -791,6 +791,13 @@ keys to browse through the directory. See .Sx USAGE EXAMPLES for examples. +If +.Ar filename +is a URL and no files or filelists were specified, +.Nm +will show +.Ar filename +and not attempt to load additional files or directories. . .Pp . -- cgit v1.2.3 From d2311c2332722ac0401e3441d9834c8b02491a82 Mon Sep 17 00:00:00 2001 From: Awal Garg Date: Mon, 30 Mar 2020 13:14:18 +0530 Subject: Enable re-using downloaded http cache --- src/imlib.c | 18 ++++++++++++++++-- src/options.c | 4 ++++ src/options.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index b9f071a..1786876 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -258,10 +258,13 @@ int feh_load_image(Imlib_Image * im, feh_file * file) file->ed = exif_get_data(tmpname); #endif } - if ((image_source != SRC_HTTP) || !opt.keep_http) + if ((image_source != SRC_HTTP) || (!opt.keep_http && !opt.use_http_cache)) unlink(tmpname); + else if (opt.use_http_cache && !opt.keep_http) + add_file_to_rm_filelist(tmpname); - free(tmpname); + if (image_source != SRC_HTTP && !opt.use_http_cache) + free(tmpname); } if ((err) || (!im)) { @@ -542,6 +545,8 @@ static char *feh_magick_load_image(char *filename) #ifdef HAVE_LIBCURL +gib_hash* http_cache = NULL; + #if LIBCURL_VERSION_NUM >= 0x072000 /* 07.32.0 */ static int curl_quit_function(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) #else @@ -576,6 +581,13 @@ static char *feh_http_load_image(char *url) char *basename; char *path = NULL; + if (opt.use_http_cache) { + if (!http_cache) + http_cache = gib_hash_new(); + if ((sfn = gib_hash_get(http_cache, url)) != NULL) + return sfn; + } + if (opt.keep_http) { if (opt.output_dir) path = opt.output_dir; @@ -648,6 +660,8 @@ static char *feh_http_load_image(char *url) free(ebuff); fclose(sfp); + if (opt.use_http_cache) + gib_hash_set(http_cache, url, sfn); return sfn; } else { weprintf("open url: fdopen failed:"); diff --git a/src/options.c b/src/options.c index aae10c2..98b3eed 100644 --- a/src/options.c +++ b/src/options.c @@ -431,6 +431,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"auto-reload" , 0, 0, 248}, #endif {"class" , 1, 0, 249}, + {"use-http-cache", 0, 0, 250}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -827,6 +828,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case 249: opt.x11_class = estrdup(optarg); break; + case 250: + opt.use_http_cache = 1; + break; default: break; } diff --git a/src/options.h b/src/options.h index 93474a9..74ef33f 100644 --- a/src/options.h +++ b/src/options.h @@ -49,6 +49,7 @@ struct __fehoptions { unsigned char aspect; unsigned char stretch; unsigned char keep_http; + unsigned char use_http_cache; unsigned char borderless; unsigned char randomize; unsigned char jump_on_resort; -- cgit v1.2.3 From a461f578e7122e1fe587892ed08ab1a364fe23b1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Mar 2020 19:23:11 +0200 Subject: Enable HTTP cache by default --- src/imlib.c | 1 + src/options.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index 1786876..6d48394 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -545,6 +545,7 @@ static char *feh_magick_load_image(char *filename) #ifdef HAVE_LIBCURL +// TODO use cache for dcraw and magick conversion results as well gib_hash* http_cache = NULL; #if LIBCURL_VERSION_NUM >= 0x072000 /* 07.32.0 */ diff --git a/src/options.c b/src/options.c index 98b3eed..eb0fbe5 100644 --- a/src/options.c +++ b/src/options.c @@ -76,6 +76,7 @@ void init_parse_options(int argc, char **argv) #ifdef HAVE_INOTIFY opt.auto_reload = 1; #endif /* HAVE_INOTIFY */ + opt.use_http_cache = 1; feh_getopt_theme(argc, argv); @@ -431,7 +432,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"auto-reload" , 0, 0, 248}, #endif {"class" , 1, 0, 249}, - {"use-http-cache", 0, 0, 250}, + {"no-conversion-cache", 0, 0, 250}, {0, 0, 0, 0} }; int optch = 0, cmdx = 0; @@ -524,6 +525,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) break; case 'R': opt.reload = atof(optarg); + opt.use_http_cache = 0; #ifdef HAVE_INOTIFY opt.auto_reload = 0; #endif @@ -829,7 +831,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) opt.x11_class = estrdup(optarg); break; case 250: - opt.use_http_cache = 1; + opt.use_http_cache = 0; break; default: break; -- cgit v1.2.3 From 4702ace25a8e65c320f65de15f8c8a7466bc0f01 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Mar 2020 19:23:18 +0200 Subject: add manpage entry for HTTP cache It's called conversion-cache for now, as it will also be used for ImageMagick/dcraw-sourced images in the future. This should also help avoid confusion between HTTP/ImageMagick/dcraw cache (files on disk), Imlib2 cache (images in memory), and thumbnail cache. --- man/feh.pre | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/man/feh.pre b/man/feh.pre index e098672..31817cc 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -578,6 +578,19 @@ Disable slideshow mode. With this setting, instead of opening multiple files in slideshow mode, multiple windows will be opened; one per file. . +.It Cm --no-conversion-cache +. +When loading images via HTTP, ImageMagick or dcraw, +.Nm +will only load/convert them once and re-use the cached file on subsequent +slideshow passes. +This option disables the cache. It is also disabled when +.Cm --reload +is used. +Use it if you rely on frequently changing files loaded via one of these +sources. +Note that it will impair performance. +. .It Cm --no-jump-on-resort . Don't jump to the first image after resorting the filelist. -- cgit v1.2.3 From 654f66211a81c0eb9d57e670c319fa60203ee1ee Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Mar 2020 19:32:14 +0200 Subject: move feh_reload_image to imlib.c (next to feh_load_image) --- src/imlib.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/slideshow.c | 76 --------------------------------------------------------- 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index 6d48394..e050126 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -322,6 +322,82 @@ int feh_load_image(Imlib_Image * im, feh_file * file) return(1); } +void feh_reload_image(winwidget w, int resize, int force_new) +{ + char *new_title; + int len; + Imlib_Image tmp; + int old_w, old_h; + + if (!w->file) { + im_weprintf(w, "couldn't reload, this image has no file associated with it."); + winwidget_render_image(w, 0, 0); + return; + } + + D(("resize %d, force_new %d\n", resize, force_new)); + + free(FEH_FILE(w->file->data)->caption); + FEH_FILE(w->file->data)->caption = NULL; + + len = strlen(w->name) + sizeof("Reloading: ") + 1; + new_title = emalloc(len); + snprintf(new_title, len, "Reloading: %s", w->name); + winwidget_rename(w, new_title); + free(new_title); + + old_w = gib_imlib_image_get_width(w->im); + old_h = gib_imlib_image_get_height(w->im); + + /* + * If we don't free the old image before loading the new one, Imlib2's + * caching will get in our way. + * However, if --reload is used (force_new == 0), we want to continue if + * the new image cannot be loaded, so we must not free the old image yet. + */ + if (force_new) + winwidget_free_image(w); + + if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { + if (force_new) + eprintf("failed to reload image\n"); + else { + im_weprintf(w, "Couldn't reload image. Is it still there?"); + winwidget_render_image(w, 0, 0); + } + return; + } + + if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) || + (old_h != gib_imlib_image_get_height(tmp)))) + resize = 1; + + if (!force_new) + winwidget_free_image(w); + + w->im = tmp; + winwidget_reset_image(w); + + w->mode = MODE_NORMAL; + if ((w->im_w != gib_imlib_image_get_width(w->im)) + || (w->im_h != gib_imlib_image_get_height(w->im))) + w->had_resize = 1; + if (w->has_rotated) { + Imlib_Image temp; + + temp = gib_imlib_create_rotated_image(w->im, 0.0); + w->im_w = gib_imlib_image_get_width(temp); + w->im_h = gib_imlib_image_get_height(temp); + gib_imlib_free_image_and_decache(temp); + } else { + w->im_w = gib_imlib_image_get_width(w->im); + w->im_h = gib_imlib_image_get_height(w->im); + } + winwidget_render_image(w, resize, 0); + + return; +} + static int feh_file_is_raw(char *filename) { childpid = fork(); diff --git a/src/slideshow.c b/src/slideshow.c index ac8c545..f807d41 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -182,82 +182,6 @@ void cb_reload_timer(void *data) return; } -void feh_reload_image(winwidget w, int resize, int force_new) -{ - char *new_title; - int len; - Imlib_Image tmp; - int old_w, old_h; - - if (!w->file) { - im_weprintf(w, "couldn't reload, this image has no file associated with it."); - winwidget_render_image(w, 0, 0); - return; - } - - D(("resize %d, force_new %d\n", resize, force_new)); - - free(FEH_FILE(w->file->data)->caption); - FEH_FILE(w->file->data)->caption = NULL; - - len = strlen(w->name) + sizeof("Reloading: ") + 1; - new_title = emalloc(len); - snprintf(new_title, len, "Reloading: %s", w->name); - winwidget_rename(w, new_title); - free(new_title); - - old_w = gib_imlib_image_get_width(w->im); - old_h = gib_imlib_image_get_height(w->im); - - /* - * If we don't free the old image before loading the new one, Imlib2's - * caching will get in our way. - * However, if --reload is used (force_new == 0), we want to continue if - * the new image cannot be loaded, so we must not free the old image yet. - */ - if (force_new) - winwidget_free_image(w); - - if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { - if (force_new) - eprintf("failed to reload image\n"); - else { - im_weprintf(w, "Couldn't reload image. Is it still there?"); - winwidget_render_image(w, 0, 0); - } - return; - } - - if (!resize && ((old_w != gib_imlib_image_get_width(tmp)) || - (old_h != gib_imlib_image_get_height(tmp)))) - resize = 1; - - if (!force_new) - winwidget_free_image(w); - - w->im = tmp; - winwidget_reset_image(w); - - w->mode = MODE_NORMAL; - if ((w->im_w != gib_imlib_image_get_width(w->im)) - || (w->im_h != gib_imlib_image_get_height(w->im))) - w->had_resize = 1; - if (w->has_rotated) { - Imlib_Image temp; - - temp = gib_imlib_create_rotated_image(w->im, 0.0); - w->im_w = gib_imlib_image_get_width(temp); - w->im_h = gib_imlib_image_get_height(temp); - gib_imlib_free_image_and_decache(temp); - } else { - w->im_w = gib_imlib_image_get_width(w->im); - w->im_h = gib_imlib_image_get_height(w->im); - } - winwidget_render_image(w, resize, 0); - - return; -} - void slideshow_change_image(winwidget winwid, int change, int render) { gib_list *last = NULL; -- cgit v1.2.3 From 6b800919b117eb3e9df405ef146feb2810b87d8f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Mar 2020 20:26:49 +0200 Subject: bypass HTTP cache when reloading an image --- src/imlib.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index e050126..2eeb37d 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -60,6 +60,11 @@ int xinerama_screen; int num_xinerama_screens; #endif /* HAVE_LIBXINERAMA */ +#ifdef HAVE_LIBCURL +// TODO use cache for dcraw and magick conversion results as well +gib_hash* http_cache = NULL; +#endif + int childpid = 0; static int feh_file_is_raw(char *filename); @@ -260,7 +265,9 @@ int feh_load_image(Imlib_Image * im, feh_file * file) } if ((image_source != SRC_HTTP) || (!opt.keep_http && !opt.use_http_cache)) unlink(tmpname); + // keep_http already performs an add_file_to_rm_filelist call else if (opt.use_http_cache && !opt.keep_http) + // add_file_to_rm_filelist duplicates tmpname add_file_to_rm_filelist(tmpname); if (image_source != SRC_HTTP && !opt.use_http_cache) @@ -358,6 +365,15 @@ void feh_reload_image(winwidget w, int resize, int force_new) if (force_new) winwidget_free_image(w); +#ifdef HAVE_LIBCURL + // if it's an external image, our own cache will also get in your way + char *sfn; + if (opt.use_http_cache && (sfn = gib_hash_get(http_cache, FEH_FILE(w->file->data)->filename)) != NULL) { + free(sfn); + gib_hash_set(http_cache, FEH_FILE(w->file->data)->filename, NULL); + } +#endif + if ((feh_load_image(&tmp, FEH_FILE(w->file->data))) == 0) { if (force_new) eprintf("failed to reload image\n"); @@ -621,9 +637,6 @@ static char *feh_magick_load_image(char *filename) #ifdef HAVE_LIBCURL -// TODO use cache for dcraw and magick conversion results as well -gib_hash* http_cache = NULL; - #if LIBCURL_VERSION_NUM >= 0x072000 /* 07.32.0 */ static int curl_quit_function(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) #else -- cgit v1.2.3