From 653a6ee83b722e430ac3068f53650dd382d9209b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Tue, 18 Feb 2014 21:10:07 +0100 Subject: [PATCH] Warn once when external key combo is used and key-handler not installed --- Makefile | 2 +- main.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 03307d8..84d8798 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION = git-20140207 +VERSION = git-20140218 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man diff --git a/main.c b/main.c index 90916e3..d5ff918 100644 --- a/main.c +++ b/main.c @@ -86,7 +86,10 @@ struct { bool open; } info; -char * keyhandler; +struct { + char *cmd; + bool warned; +} keyhandler; timeout_t timeouts[] = { { { 0, 0 }, false, redraw }, @@ -453,7 +456,14 @@ void run_key_handler(const char *key, unsigned int mask) char kstr[32]; struct stat oldst, newst; - if (keyhandler == NULL || key == NULL) + if (keyhandler.cmd == NULL) { + if (!keyhandler.warned) { + warn("key handler not installed"); + keyhandler.warned = true; + } + return; + } + if (key == NULL) return; snprintf(kstr, sizeof(kstr), "%s%s%s%s", @@ -464,7 +474,7 @@ void run_key_handler(const char *key, unsigned int mask) stat(files[n].path, &oldst); if ((pid = fork()) == 0) { - execl(keyhandler, keyhandler, kstr, files[n].path, NULL); + execl(keyhandler.cmd, keyhandler.cmd, kstr, files[n].path, NULL); warn("could not exec key handler"); exit(EXIT_FAILURE); } else if (pid < 0) { @@ -810,7 +820,7 @@ int main(int argc, char **argv) dsuffix = "/.config"; } if (homedir != NULL) { - char **cmd[] = { &info.cmd, &keyhandler }; + char **cmd[] = { &info.cmd, &keyhandler.cmd }; const char *name[] = { "image-info", "key-handler" }; for (i = 0; i < ARRLEN(cmd); i++) {