From ecf6f6ebbbe9f66eaf70ce738f8c19e99d3be969 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 13 Dec 2007 11:04:48 +0100 Subject: [PATCH] save default configuration file on first run without conf file --- config.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config.c b/config.c index 1f32e6d7..b2a8019b 100644 --- a/config.c +++ b/config.c @@ -305,6 +305,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) ssize_t confpath_len; Key *key = NULL; Rule *rule = NULL; + FILE *defconfig = NULL; if(confpatharg) confpath = a_strdup(confpatharg); @@ -327,6 +328,8 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) { perror("awesome: parsing configuration file failed"); cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG); + if(!(defconfig = fopen(confpath, "w"))) + perror("awesome: unable to create default configuration file"); } else if(ret == CFG_PARSE_ERROR) cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); @@ -528,6 +531,12 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) else awesomeconf->keys = NULL; + if(defconfig) + { + cfg_print(cfg, defconfig); + fclose(defconfig); + } + /* Free! Like a river! */ cfg_free(cfg); p_delete(&confpath);