Warn once when external key combo is used and key-handler not installed

This commit is contained in:
Bert Münnich 2014-02-18 21:10:07 +01:00
parent d049391916
commit 653a6ee83b
2 changed files with 15 additions and 5 deletions

View File

@ -1,4 +1,4 @@
VERSION = git-20140207 VERSION = git-20140218
PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man MANPREFIX = $(PREFIX)/share/man

18
main.c
View File

@ -86,7 +86,10 @@ struct {
bool open; bool open;
} info; } info;
char * keyhandler; struct {
char *cmd;
bool warned;
} keyhandler;
timeout_t timeouts[] = { timeout_t timeouts[] = {
{ { 0, 0 }, false, redraw }, { { 0, 0 }, false, redraw },
@ -453,7 +456,14 @@ void run_key_handler(const char *key, unsigned int mask)
char kstr[32]; char kstr[32];
struct stat oldst, newst; 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; return;
snprintf(kstr, sizeof(kstr), "%s%s%s%s", 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); stat(files[n].path, &oldst);
if ((pid = fork()) == 0) { 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"); warn("could not exec key handler");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else if (pid < 0) { } else if (pid < 0) {
@ -810,7 +820,7 @@ int main(int argc, char **argv)
dsuffix = "/.config"; dsuffix = "/.config";
} }
if (homedir != NULL) { if (homedir != NULL) {
char **cmd[] = { &info.cmd, &keyhandler }; char **cmd[] = { &info.cmd, &keyhandler.cmd };
const char *name[] = { "image-info", "key-handler" }; const char *name[] = { "image-info", "key-handler" };
for (i = 0; i < ARRLEN(cmd); i++) { for (i = 0; i < ARRLEN(cmd); i++) {