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;
|
ssize_t confpath_len;
|
||||||
Key *key = NULL;
|
Key *key = NULL;
|
||||||
Rule *rule = NULL;
|
Rule *rule = NULL;
|
||||||
|
FILE *defconfig = NULL;
|
||||||
|
|
||||||
if(confpatharg)
|
if(confpatharg)
|
||||||
confpath = a_strdup(confpatharg);
|
confpath = a_strdup(confpatharg);
|
||||||
|
@ -327,6 +328,8 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
perror("awesome: parsing configuration file failed");
|
perror("awesome: parsing configuration file failed");
|
||||||
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
|
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)
|
else if(ret == CFG_PARSE_ERROR)
|
||||||
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
|
||||||
|
@ -528,6 +531,12 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
else
|
else
|
||||||
awesomeconf->keys = NULL;
|
awesomeconf->keys = NULL;
|
||||||
|
|
||||||
|
if(defconfig)
|
||||||
|
{
|
||||||
|
cfg_print(cfg, defconfig);
|
||||||
|
fclose(defconfig);
|
||||||
|
}
|
||||||
|
|
||||||
/* Free! Like a river! */
|
/* Free! Like a river! */
|
||||||
cfg_free(cfg);
|
cfg_free(cfg);
|
||||||
p_delete(&confpath);
|
p_delete(&confpath);
|
||||||
|
|
Loading…
Reference in New Issue