save default configuration file on first run without conf file
This commit is contained in:
parent
5f811b1cf2
commit
ecf6f6ebbb
9
config.c
9
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);
|
||||
|
|
Loading…
Reference in New Issue