summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--TODO80
-rw-r--r--man/feh.pre8
-rw-r--r--src/feh.h3
-rw-r--r--src/imlib.c42
-rw-r--r--src/keyevents.c14
-rw-r--r--src/list.c7
-rw-r--r--src/main.c2
-rw-r--r--src/multiwindow.c2
-rw-r--r--src/options.c5
-rw-r--r--src/options.h2
-rw-r--r--src/signals.c34
-rw-r--r--src/slideshow.c9
-rw-r--r--src/thumbnail.c1
-rw-r--r--test/feh.t12
15 files changed, 159 insertions, 72 deletions
diff --git a/ChangeLog b/ChangeLog
index 170e89b..9ea7774 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+git HEAD
+
+ * Add R, * and / aliases for <keypad begin>, <keypad *> and <keypad />
+ * 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}
+ * 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 <derf@finalrewind.org>
* Release v2.4
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
+
diff --git a/man/feh.pre b/man/feh.pre
index a402c8c..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
.
@@ -1151,7 +1153,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 +1165,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/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..eda3e2a 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 = 0;
+
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,27 +282,52 @@ 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, 0);
dup2(devnull, 1);
dup2(devnull, 2);
+ /*
+ * convert only accepts SIGINT via killpg, a normal kill doesn't work
+ */
+ 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);
+ }
+
+ /*
+ * 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);
}
+ childpid = 0;
}
return sfn;
diff --git a/src/keyevents.c b/src/keyevents.c
index 0ada751..343b5d1 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);
@@ -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)) {
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 5891056..e6239e1 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;
@@ -43,6 +44,7 @@ int main(int argc, char **argv)
init_parse_options(argc, argv);
init_imlib_fonts();
+ setup_signal_handlers();
if (opt.display) {
init_x_and_imlib();
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..0b18aac 100644
--- a/src/signals.c
+++ b/src/signals.c
@@ -36,9 +36,13 @@ 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) ||
+ (sigaddset(&feh_ss, SIGTERM) == -1) ||
+ (sigaddset(&feh_ss, SIGQUIT) == -1) ||
+ (sigaddset(&feh_ss, SIGINT) == -1))
{
- weprintf("Failed to set up signal mask, SIGUSR1/2 won't work");
+ weprintf("Failed to set up signal masks");
return;
}
@@ -48,9 +52,13 @@ 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) ||
+ (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, SIGUSR1/2 won't work");
+ weprintf("Failed to set up signal handler");
return;
}
@@ -59,10 +67,24 @@ 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;
+ 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) {
if (signo == SIGUSR1)
slideshow_change_image(winwid, SLIDE_NEXT, 1);
diff --git a/src/slideshow.c b/src/slideshow.c
index a868a44..337e202 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;
}
@@ -266,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)
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;
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('');