JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
add xlock to list that isnt verified during startup
[spectrwm.git] / spectrwm.c
index 1522296..21310f7 100644 (file)
@@ -6018,7 +6018,9 @@ setspawn(const char *name, const char *args)
 int
 setconfspawn(char *selector, char *value, int flags)
 {
-       char *args;
+       char            *args;
+       char            which[PATH_MAX];
+       size_t          i;
 
        /* suppress unused warning since var is needed */
        (void)flags;
@@ -6027,6 +6029,17 @@ setconfspawn(char *selector, char *value, int flags)
 
        DNPRINTF(SWM_D_SPAWN, "setconfspawn: [%s] [%s]\n", selector, args);
 
+       /* verify we have the goods */
+       snprintf(which, sizeof which, "which %s", value);
+       for (i = strlen("which "); i < strlen(which); i++)
+               if (which[i] == ' ') {
+                       which[i] = '\0';
+                       break;
+               }
+       if (flags == 0 && system(which) != 0)
+               add_startup_exception("could not find %s",
+                   &which[strlen("which ")]);
+
        setspawn(selector, args);
        free(args);
 
@@ -6039,10 +6052,6 @@ setup_spawn(void)
 {
        setconfspawn("term",            "xterm",                0);
        setconfspawn("spawn_term",      "xterm",                0);
-       setconfspawn("screenshot_all",  "screenshot.sh full",   0);
-       setconfspawn("screenshot_wind", "screenshot.sh window", 0);
-       setconfspawn("lock",            "xlock",                0);
-       setconfspawn("initscr",         "initscreen.sh",        0);
        setconfspawn("menu",            "dmenu_run"
                                        " -fn $bar_font"
                                        " -nb $bar_color"
@@ -6064,9 +6073,12 @@ setup_spawn(void)
                                        " -sb $bar_border"
                                        " -sf $bar_color",      0);
 
-       /* only test dmenu for now, really should expand this */
-       if (system("dmenu -v") != 0)
-               add_startup_exception("you must install dmenu");
+       /* these are not verified for existence */
+       setconfspawn("lock",            "xlock",                1);
+       setconfspawn("screenshot_all",  "screenshot.sh full",   1);
+       setconfspawn("screenshot_wind", "screenshot.sh window", 1);
+       setconfspawn("initscr",         "initscreen.sh",        1);
+
 }
 
 /* key bindings */
@@ -7307,6 +7319,12 @@ conf_load(const char *filename, int keymapping)
                cp += strspn(cp, "= \t\n"); /* eat trailing */
                /* get RHS value */
                optval = strdup(cp);
+               if (strlen(optval) == 0) {
+                       add_startup_exception("%s: line %zd: must supply value "
+                           "to %s", filename, lineno,
+                           configopt[optidx].optname);
+                       goto invalid;
+               }
                /* call function to deal with it all */
                if (configopt[optidx].func(optsub, optval,
                    configopt[optidx].funcflags) != 0) {