diff options
author | okan | 2012-12-18 00:14:41 +0000 |
---|---|---|
committer | okan | 2012-12-18 00:14:41 +0000 |
commit | 36bf81830c116600c1ee9f8c0fc8423f6e642a89 (patch) | |
tree | 21f8f33a7411e11caf0cabc2c929d31ab96117fe /calmwm.c | |
parent | 3a90166d0b310afb7339b6d1eebd8bb37a80324f (diff) | |
download | cwm-36bf81830c116600c1ee9f8c0fc8423f6e642a89.tar.gz |
simplify config file setup; with Tiago Cunha
Diffstat (limited to 'calmwm.c')
-rw-r--r-- | calmwm.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.71 2012/12/17 23:03:41 okan Exp $ + * $OpenBSD: calmwm.c,v 1.72 2012/12/18 00:14:41 okan Exp $ */ #include <sys/param.h> @@ -62,7 +62,7 @@ int main(int argc, char **argv) { const char *conf_file = NULL; - char *display_name = NULL; + char *conf_path, *display_name = NULL; int ch; struct passwd *pw; @@ -97,10 +97,25 @@ main(int argc, char **argv) homedir = "/"; } + if (conf_file == NULL) + xasprintf(&conf_path, "%s/%s", homedir, CONFFILE); + else + conf_path = xstrdup(conf_file); + + if (access(conf_path, R_OK) != 0) { + if (conf_file != NULL) + warn("%s", conf_file); + free(conf_path); + conf_path = NULL; + } + dpy_init(display_name); - bzero(&Conf, sizeof(Conf)); - conf_setup(&Conf, conf_file); + conf_init(&Conf); + if (conf_path && (parse_config(conf_path, &Conf) == -1)) + warnx("config file %s has errors, not loading", conf_path); + free(conf_path); + xu_getatoms(); x_setup(); xev_loop(); |