summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-02-18 21:10:07 +0100
committerBert Münnich <ber.t@posteo.de>2014-02-18 21:10:44 +0100
commit653a6ee83b722e430ac3068f53650dd382d9209b (patch)
treea72638920008d5a60b66bf517577830e5e45795a /main.c
parentd049391916e4f418d6057bca9fcbd3d6e35cd15a (diff)
downloadnsxiv-653a6ee83b722e430ac3068f53650dd382d9209b.tar.zst
Warn once when external key combo is used and key-handler not installed
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 14 insertions, 4 deletions
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++) {