From cbab594f051b5c21a76d0ad389a25d6449e0b839 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 12 Mar 2012 12:44:56 +0100 Subject: Add alternative defaults for numpad keybindings (closes #84) --- man/feh.pre | 6 +++--- src/keyevents.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man/feh.pre b/man/feh.pre index a402c8c..48d7778 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -1151,7 +1151,7 @@ Scroll up by one page . Scroll down by one page . -.It Ao keypad begin Ac Bq render +.It R, Ao keypad begin Ac Bq render . Antialias the image . @@ -1163,11 +1163,11 @@ Zoom in . Zoom out . -.It Ao keypad * Ac Bq zoom_default +.It *, Ao keypad * Ac Bq zoom_default . Zoom to 100% . -.It Ao keypad / Ac Bq zoom_fit +.It /, Ao keypad / Ac Bq zoom_fit . Zoom to fit the window size . diff --git a/src/keyevents.c b/src/keyevents.c index 0ada751..6327320 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -129,10 +129,10 @@ void init_keyevents(void) { feh_set_kb(&keys.action_9 , 0, XK_9 , 0, XK_KP_9 , 0, 0); feh_set_kb(&keys.zoom_in , 0, XK_Up , 0, XK_KP_Add , 0, 0); feh_set_kb(&keys.zoom_out , 0, XK_Down , 0, XK_KP_Subtract,0, 0); - feh_set_kb(&keys.zoom_default, 0, XK_KP_Multiply, 0, 0 , 0, 0); - feh_set_kb(&keys.zoom_fit , 0, XK_KP_Divide , 0, 0 , 0, 0); + feh_set_kb(&keys.zoom_default, 0, XK_KP_Multiply, 0, XK_asterisk, 0, 0); + feh_set_kb(&keys.zoom_fit , 0, XK_KP_Divide , 0, XK_slash , 0, 0); feh_set_kb(&keys.size_to_image, 0, XK_w , 0, 0 , 0, 0); - feh_set_kb(&keys.render , 0, XK_KP_Begin , 0, 0 , 0, 0); + feh_set_kb(&keys.render , 0, XK_KP_Begin , 0, XK_R , 0, 0); feh_set_kb(&keys.toggle_actions, 0, XK_a, 0, 0, 0, 0); feh_set_kb(&keys.toggle_aliasing, 0, XK_A, 0, 0, 0, 0); feh_set_kb(&keys.toggle_filenames, 0, XK_d, 0, 0, 0, 0); -- cgit v1.2.3 From 8f5bf736a9d3f8084c644dbf6ceefc4142715c4e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Mar 2012 00:45:13 +0100 Subject: Experimental code to limit imagemagick convert runtime (see #82) Problems so far: * leaks zombie processes * does not work when terminating feh with a signal (since the convert process is no longer in feh's process group) --- src/feh.h | 3 +++ src/imlib.c | 30 ++++++++++++++++++++++++------ src/main.c | 2 ++ src/multiwindow.c | 2 -- src/options.c | 5 +++++ src/options.h | 2 ++ src/signals.c | 20 ++++++++++++++------ src/slideshow.c | 2 -- src/thumbnail.c | 1 + 9 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/feh.h b/src/feh.h index 7088dea..1d48e53 100644 --- a/src/feh.h +++ b/src/feh.h @@ -188,4 +188,7 @@ extern feh_menu *menu_main; extern feh_menu *menu_close; extern char *mode; /* label for the current mode */ +/* to terminate long-running children with SIGALRM */ +extern int childpid; + #endif diff --git a/src/imlib.c b/src/imlib.c index c0252c3..1e4eb3f 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -59,6 +59,8 @@ int xinerama_screen; int num_xinerama_screens; #endif /* HAVE_LIBXINERAMA */ +int childpid; + static char *feh_http_load_image(char *url); static char *feh_magick_load_image(char *filename); @@ -253,7 +255,10 @@ static char *feh_magick_load_image(char *filename) char *tmpname; char *sfn; int fd = -1, devnull = -1; - int pid, status; + int status; + + if (opt.magick_timeout < 0) + return NULL; basename = strrchr(filename, '/'); @@ -277,26 +282,39 @@ static char *feh_magick_load_image(char *filename) snprintf(argv_fd, sizeof(argv_fd), "png:fd:%d", fd); - - if ((pid = fork()) == 0) { + if ((childpid = fork()) == 0) { /* discard convert output */ devnull = open("/dev/null", O_WRONLY); dup2(devnull, 1); dup2(devnull, 2); + /* + * convert only accepts SIGINT via killpg, a normal kill doesn't work + */ + if (opt.magick_timeout) + setpgid(0, 0); + execlp("convert", "convert", filename, argv_fd, NULL); exit(1); } else { - waitpid(pid, &status, 0); + alarm(opt.magick_timeout); + waitpid(childpid, &status, 0); + alarm(0); if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { close(fd); unlink(sfn); sfn = NULL; - if (!opt.quiet) - weprintf("%s - No loader for that file format", filename); + if (!opt.quiet) { + if (WIFSIGNALED(status)) + weprintf("%s - Conversion took too long, skipping", + filename); + else + weprintf("%s - No loader for that file format", + filename); + } } } diff --git a/src/main.c b/src/main.c index 5891056..a5694fb 100644 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "timers.h" #include "options.h" #include "events.h" +#include "signals.h" #include "wallpaper.h" char **cmdargv = NULL; @@ -48,6 +49,7 @@ int main(int argc, char **argv) init_x_and_imlib(); init_keyevents(); init_buttonbindings(); + setup_signal_handlers(); } feh_event_init(); diff --git a/src/multiwindow.c b/src/multiwindow.c index 1bd8a8a..9797fb0 100644 --- a/src/multiwindow.c +++ b/src/multiwindow.c @@ -65,7 +65,5 @@ void init_multiwindow_mode(void) free(s); } - setup_signal_handlers(); - return; } diff --git a/src/options.c b/src/options.c index f389e0e..a277003 100644 --- a/src/options.c +++ b/src/options.c @@ -53,6 +53,7 @@ void init_parse_options(int argc, char **argv) opt.display = 1; opt.aspect = 1; opt.slideshow_delay = 0.0; + opt.magick_timeout = 10; opt.thumb_w = 60; opt.thumb_h = 60; opt.thumb_redraw = 10; @@ -378,6 +379,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) {"zoom" , 1, 0, 205}, {"no-screen-clip", 0, 0, 206}, {"index-info" , 1, 0, 207}, + {"magick-timeout", 1, 0, 208}, {"caption-path" , 1, 0, 'K'}, {"action1" , 1, 0, 209}, {"action2" , 1, 0, 210}, @@ -646,6 +648,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun) case 207: opt.index_info = estrdup(optarg); break; + case 208: + opt.magick_timeout = atoi(optarg); + break; case 'K': opt.caption_path = estrdup(optarg); break; diff --git a/src/options.h b/src/options.h index bee7c73..898e9ff 100644 --- a/src/options.h +++ b/src/options.h @@ -117,6 +117,8 @@ struct __fehoptions { double slideshow_delay; + signed short magick_timeout; + Imlib_Font menu_fn; }; diff --git a/src/signals.c b/src/signals.c index d5a6899..91f6bf3 100644 --- a/src/signals.c +++ b/src/signals.c @@ -36,9 +36,10 @@ void setup_signal_handlers() if ( (sigemptyset(&feh_ss) == -1) || (sigaddset(&feh_ss, SIGUSR1) == -1) || - (sigaddset(&feh_ss, SIGUSR2) == -1)) + (sigaddset(&feh_ss, SIGUSR2) == -1) || + (sigaddset(&feh_ss, SIGALRM) == -1)) { - weprintf("Failed to set up signal mask, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal masks"); return; } @@ -48,9 +49,10 @@ void setup_signal_handlers() if ( (sigaction(SIGUSR1, &feh_sh, NULL) == -1) || - (sigaction(SIGUSR2, &feh_sh, NULL) == -1)) + (sigaction(SIGUSR2, &feh_sh, NULL) == -1) || + (sigaction(SIGALRM, &feh_sh, NULL) == -1)) { - weprintf("Failed to set up signal handler, SIGUSR1/2 won't work"); + weprintf("Failed to set up signal handler"); return; } @@ -59,10 +61,16 @@ void setup_signal_handlers() void feh_handle_signal(int signo) { - winwidget winwid - = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + winwidget winwid; int i; + if (signo == SIGALRM) { + killpg(childpid, SIGINT); + kill(childpid, SIGINT); + return; + } + winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); + if (winwid) { if (signo == SIGUSR1) slideshow_change_image(winwid, SLIDE_NEXT, 1); diff --git a/src/slideshow.c b/src/slideshow.c index a868a44..0f67917 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -76,8 +76,6 @@ void init_slideshow_mode(void) if (!success) show_mini_usage(); - setup_signal_handlers(); - return; } diff --git a/src/thumbnail.c b/src/thumbnail.c index b13b3d8..f276592 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -32,6 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "md5.h" #include "feh_png.h" #include "index.h" +#include "signals.h" static gib_list *thumbnails = NULL; -- cgit v1.2.3 From 57e2af2763ee87bafb368390fd18382c957fd27e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 13 Mar 2012 14:22:27 +0100 Subject: slideshow_change_image: do not jump to current image on random jump (closes #85) --- src/slideshow.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slideshow.c b/src/slideshow.c index 0f67917..337e202 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -264,8 +264,11 @@ void slideshow_change_image(winwidget winwid, int change, int render) current_file = feh_list_jump(filelist, current_file, BACK, 1); break; case SLIDE_RAND: - current_file = feh_list_jump(filelist, current_file, FORWARD, rand() % filelist_len); - change = SLIDE_NEXT; + if (filelist_len > 1) { + current_file = feh_list_jump(filelist, current_file, FORWARD, + (rand() % (filelist_len - 1)) + 1); + change = SLIDE_NEXT; + } break; case SLIDE_JUMP_FWD: if (filelist_len < 5) -- cgit v1.2.3 From 86a6ae59b3b2b63fd71c4668bfcf33d6fea8448b Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 14 Mar 2012 13:09:02 +0100 Subject: imlib.c: "Fix" Zombie issue Still to do: signal handler for sigint/quit/term --- src/imlib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/imlib.c b/src/imlib.c index 1e4eb3f..d83cc08 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -315,6 +315,17 @@ static char *feh_magick_load_image(char *filename) weprintf("%s - No loader for that file format", filename); } + + /* + * Reap child. The previous waitpid call was interrupted by + * alarm, but convert doesn't terminate immediately. + * XXX + * normally, if (WIFSIGNALED(status)) waitpid(childpid, &status, 0); + * would suffice. However, as soon as feh has its own window, + * this doesn't work anymore and the following workaround is + * required. Hm. + */ + waitpid(-1, &status, 0); } } -- cgit v1.2.3 From 1f4029b244eef2cd956447cae46ab5a194a8916c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 14 Mar 2012 13:34:48 +0100 Subject: Terminate convert when receiving SIG{INT,TERM,QUIT} --- src/imlib.c | 3 ++- src/signals.c | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index d83cc08..090159c 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -59,7 +59,7 @@ int xinerama_screen; int num_xinerama_screens; #endif /* HAVE_LIBXINERAMA */ -int childpid; +int childpid = 0; static char *feh_http_load_image(char *url); static char *feh_magick_load_image(char *filename); @@ -327,6 +327,7 @@ static char *feh_magick_load_image(char *filename) */ waitpid(-1, &status, 0); } + childpid = 0; } return sfn; diff --git a/src/signals.c b/src/signals.c index 91f6bf3..0b18aac 100644 --- a/src/signals.c +++ b/src/signals.c @@ -37,7 +37,10 @@ void setup_signal_handlers() (sigemptyset(&feh_ss) == -1) || (sigaddset(&feh_ss, SIGUSR1) == -1) || (sigaddset(&feh_ss, SIGUSR2) == -1) || - (sigaddset(&feh_ss, SIGALRM) == -1)) + (sigaddset(&feh_ss, SIGALRM) == -1) || + (sigaddset(&feh_ss, SIGTERM) == -1) || + (sigaddset(&feh_ss, SIGQUIT) == -1) || + (sigaddset(&feh_ss, SIGINT) == -1)) { weprintf("Failed to set up signal masks"); return; @@ -50,7 +53,10 @@ void setup_signal_handlers() if ( (sigaction(SIGUSR1, &feh_sh, NULL) == -1) || (sigaction(SIGUSR2, &feh_sh, NULL) == -1) || - (sigaction(SIGALRM, &feh_sh, NULL) == -1)) + (sigaction(SIGALRM, &feh_sh, NULL) == -1) || + (sigaction(SIGTERM, &feh_sh, NULL) == -1) || + (sigaction(SIGQUIT, &feh_sh, NULL) == -1) || + (sigaction(SIGINT, &feh_sh, NULL) == -1)) { weprintf("Failed to set up signal handler"); return; @@ -64,11 +70,19 @@ void feh_handle_signal(int signo) winwidget winwid; int i; - if (signo == SIGALRM) { - killpg(childpid, SIGINT); - kill(childpid, SIGINT); - return; + switch (signo) { + case SIGALRM: + if (childpid) + killpg(childpid, SIGINT); + return; + case SIGINT: + case SIGTERM: + case SIGQUIT: + if (childpid) + killpg(childpid, SIGINT); + exit(128 + signo); } + winwid = winwidget_get_first_window_of_type(WIN_TYPE_SLIDESHOW); if (winwid) { -- cgit v1.2.3 From 4abe611c0b525681b68b2181b0bf27c72809f7ec Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 14 Mar 2012 18:48:17 +0100 Subject: Update TODO (via github) --- TODO | 80 +++++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/TODO b/TODO index 9ce1b5c..f7dbbac 100644 --- a/TODO +++ b/TODO @@ -79,19 +79,6 @@ the dependency might be an idea updated: 2011/11/29 13:34:35 -0800 comments: 2 -54. proper support for tiling WMs [was: zoom to window size] ------------------------------------------------------------- -i frequently use feh with a tiling window manager. it would be great if there -were a switch that automatically zoomed the image to the window size (like with -fullscreen, but without actually changing the window size). right now i need to -specify the exact geometry to get this to work correctly. - state: open - user: ecraven - votes: 0 - created: 2011/08/11 03:15:38 -0700 - updated: 2011/10/31 02:20:16 -0700 - comments: 8 - 67. receive commands from the terminal that started feh ------------------------------------------------------- I am running feh on a remote machine by starting it from a ssh terminal. I @@ -119,34 +106,6 @@ window size. Gotta fix that. updated: 2011/11/27 18:59:58 -0800 comments: 1 -73. Position and Maximum Size of feh window -------------------------------------------- -The --geometry lets you specify a fixed size and location for the window - -BUG: specifying just a location is positioned right but produces a checkerboard -display! - feh --geometry +50+5 vary_large_image.jpg -No image gets displayed - - - -Full screen also does not take into account things like a bottom panel. and -Window Decorations. -I wouldn't expect it to, as it is not always something that can be determined. -Instead allowing the user -to specify display limits (placement and the size for --scale-down) would seem -a better method. -Especially when you do not want checkerboard. - -An option to center the window in that area would also work well but not -nessary! - state: open - user: antofthy - votes: 0 - created: 2011/11/23 00:07:41 -0800 - updated: 2011/11/26 03:52:45 -0800 - comments: 0 - 75. image opened by thumbnail mode is in position 0 of the filelist ------------------------------------------------------------------- 1. @@ -191,3 +150,42 @@ and 3rd mouse buttons. updated: 2012/01/27 00:53:05 -0800 comments: 2 +81. zoom, scale-down etc. are a huge mess +----------------------------------------- +* when using feh --scale-down, the middle button toggles between zoom 100% and +zoom to fit. It should only set zoom to 100% +* --scale-down: removing the zoom = 1.001 workaround from keyevents.c, zoom +100% -> zoom in / out breaks +* same for events.c, except there's no workaround in place + state: open + user: derf + votes: 0 + created: 2012/03/06 04:12:09 -0800 + comments: 0 + +82. feh loads movies with convert +--------------------------------- +feh loads movies with convert. That takes a very long time, because I only have +5 gigabytes of RAM. (pun intended) That is probably an unintended "feature" +introduced by commit ba08d4b25fcbcd4e16388673184cf4d179dbd420. + +For my needs it would be best if I could disable the call to convert by default +(maybe a new config file?), while providing a command line argument reenabling +the convert feature. (for the rare occasions when I use really obscure file +formats) + state: open + user: pyropeter + votes: 0 + created: 2012/03/07 13:25:32 -0800 + updated: 2012/03/10 06:49:16 -0800 + comments: 3 + +83. add keybindings for brightness / contrast adjustment +-------------------------------------------------------- +Requested by mail: for example, b/B for brightness and k/K for contrast. + state: open + user: derf + votes: 0 + created: 2012/03/10 05:40:36 -0800 + comments: 0 + -- cgit v1.2.3 From 8899df700027280ad34c7ee64f2aadfc3ae8e6c8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 14 Mar 2012 20:30:30 +0100 Subject: changelog --- ChangeLog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 170e89b..6d21cd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +git HEAD + + * Add R, * and / aliases for , and + * Try to convert unloadable files with imagemagick for up to 6 seconds + * Add --magick-timeout option to set imagemagick conversion timeout or + disable it altogether + * Clean up temporary / to-delete files when receiveng SIG{INT,TERM,QUIT} + Tue, 06 Mar 2012 13:13:35 +0100 Daniel Friesel * Release v2.4 -- cgit v1.2.3 From 489b73d5f479dce3c70bab50b8663bdf1527b2cf Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 15 Mar 2012 17:40:42 +0100 Subject: scroll keys: Sanitise offsets before rendering --- ChangeLog | 1 + src/keyevents.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6d21cd7..4bf4a4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ git HEAD * Add --magick-timeout option to set imagemagick conversion timeout or disable it altogether * Clean up temporary / to-delete files when receiveng SIG{INT,TERM,QUIT} + * Do not scroll past image borders when using key bindings Tue, 06 Mar 2012 13:13:35 +0100 Daniel Friesel diff --git a/src/keyevents.c b/src/keyevents.c index 6327320..343b5d1 100644 --- a/src/keyevents.c +++ b/src/keyevents.c @@ -479,34 +479,42 @@ void feh_event_handle_keypress(XEvent * ev) } else if (feh_is_kp(&keys.scroll_right, keysym, state)) { winwid->im_x -= 20; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_left, keysym, state)) { winwid->im_x += 20; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_down, keysym, state)) { winwid->im_y -= 20; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_up, keysym, state)) { winwid->im_y += 20; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 1); } else if (feh_is_kp(&keys.scroll_right_page, keysym, state)) { winwid->im_x -= winwid->w; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_left_page, keysym, state)) { winwid->im_x += winwid->w; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_down_page, keysym, state)) { winwid->im_y -= winwid->h; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.scroll_up_page, keysym, state)) { winwid->im_y += winwid->h; + winwidget_sanitise_offsets(winwid); winwidget_render_image(winwid, 0, 0); } else if (feh_is_kp(&keys.jump_back, keysym, state)) { -- cgit v1.2.3 From 338553950063615b59d80d2148d208b490c3d0bd Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 15 Mar 2012 21:07:50 +0100 Subject: feh_magick_load_image: close stdin as well --- src/imlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imlib.c b/src/imlib.c index 090159c..eda3e2a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -286,14 +286,14 @@ static char *feh_magick_load_image(char *filename) /* discard convert output */ devnull = open("/dev/null", O_WRONLY); + dup2(devnull, 0); dup2(devnull, 1); dup2(devnull, 2); /* * convert only accepts SIGINT via killpg, a normal kill doesn't work */ - if (opt.magick_timeout) - setpgid(0, 0); + setpgid(0, 0); execlp("convert", "convert", filename, argv_fd, NULL); exit(1); -- cgit v1.2.3 From 29cd868898660c58b1925bf3647c4c63b7bd3151 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 15 Mar 2012 21:16:16 +0100 Subject: --(un|)loadable: indicate results in exit code --- ChangeLog | 1 + man/feh.pre | 2 ++ src/list.c | 7 ++++++- src/main.c | 2 +- test/feh.t | 12 ++++++------ 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bf4a4b..9ea7774 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ git HEAD disable it altogether * Clean up temporary / to-delete files when receiveng SIG{INT,TERM,QUIT} * Do not scroll past image borders when using key bindings + * --loadable / --unloadable: indicate result in exit status Tue, 06 Mar 2012 13:13:35 +0100 Daniel Friesel diff --git a/man/feh.pre b/man/feh.pre index 48d7778..ecd35ec 100644 --- a/man/feh.pre +++ b/man/feh.pre @@ -383,6 +383,7 @@ size/resolution/type etc. . Don't display images. Just print out their names if imlib2 can successfully load them. +Returns false if at least one image failed to load. . .It Cm -M , --menu-font Ar font . @@ -550,6 +551,7 @@ mode. See . Don't display images. Just print out their names if imlib2 can NOT successfully load them. +Returns false if at least one image was loadable. . .It Cm -V , --verbose . diff --git a/src/list.c b/src/list.c index 17fcbcc..2affe85 100644 --- a/src/list.c +++ b/src/list.c @@ -77,6 +77,7 @@ void real_loadables_mode(int loadable) { feh_file *file; gib_list *l; + char ret = 0; opt.quiet = 1; @@ -91,6 +92,8 @@ void real_loadables_mode(int loadable) puts(file->filename); feh_action_run(file, opt.actions[0]); } + else + ret = 1; gib_imlib_free_image_and_decache(im); } else { /* Oh dear. */ @@ -98,7 +101,9 @@ void real_loadables_mode(int loadable) puts(file->filename); feh_action_run(file, opt.actions[0]); } + else + ret = 1; } } - exit(0); + exit(ret); } diff --git a/src/main.c b/src/main.c index a5694fb..e6239e1 100644 --- a/src/main.c +++ b/src/main.c @@ -44,12 +44,12 @@ int main(int argc, char **argv) init_parse_options(argc, argv); init_imlib_fonts(); + setup_signal_handlers(); if (opt.display) { init_x_and_imlib(); init_keyevents(); init_buttonbindings(); - setup_signal_handlers(); } feh_event_init(); diff --git a/test/feh.t b/test/feh.t index 1c6556c..8746362 100644 --- a/test/feh.t +++ b/test/feh.t @@ -45,7 +45,7 @@ $cmd->stderr_is_eq(''); $cmd = Test::Command->new(cmd => "$feh --loadable $images"); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_like($re_loadable); $cmd->stderr_is_eq(''); @@ -53,7 +53,7 @@ $cmd = Test::Command->new( cmd => "$feh --loadable --action 'echo touch %f' $images" ); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/loadable_action'); $cmd->stderr_is_eq(''); @@ -61,7 +61,7 @@ $cmd = Test::Command->new( cmd => "$feh --loadable --action ';echo touch %f' $images" ); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/loadable_naction'); $cmd->stderr_is_eq(''); @@ -69,7 +69,7 @@ $cmd = Test::Command->new( cmd => "$feh --unloadable --action 'echo rm %f' $images" ); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/unloadable_action'); $cmd->stderr_is_eq(''); @@ -77,13 +77,13 @@ $cmd = Test::Command->new( cmd => "$feh --unloadable --action ';echo rm %f' $images" ); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_is_file('test/nx_action/unloadable_naction'); $cmd->stderr_is_eq(''); $cmd = Test::Command->new(cmd => "$feh --unloadable $images"); -$cmd->exit_is_num(0); +$cmd->exit_is_num(1); $cmd->stdout_like($re_unloadable); $cmd->stderr_is_eq(''); -- cgit v1.2.3