mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-21 01:40:16 -05:00
config: apply overrides even if there's no file
Previously, foot -a test wouldn't actually set the app ID if there was no config file and the defaults were used, which was very counterintuitive. Now, load_config() will carry on until the end, even if there's no config file, so overrides still work.
This commit is contained in:
parent
7fcbca808b
commit
400a3f5ad2
2 changed files with 21 additions and 22 deletions
|
|
@ -80,10 +80,14 @@
|
||||||
opened/activated ([#1474][1474]).
|
opened/activated ([#1474][1474]).
|
||||||
* `XTGETTCAP` with capabilities that are not properly hex encoded will
|
* `XTGETTCAP` with capabilities that are not properly hex encoded will
|
||||||
be ignored, instead of echo:ed back to the TTY in an error response.
|
be ignored, instead of echo:ed back to the TTY in an error response.
|
||||||
|
* Command line configuration overrides are now applied even if the
|
||||||
|
configuration file does not exist or can't be
|
||||||
|
parsed. ([#1495][1495]).
|
||||||
|
|
||||||
[1391]: https://codeberg.org/dnkl/foot/issues/1391
|
[1391]: https://codeberg.org/dnkl/foot/issues/1391
|
||||||
[1448]: https://codeberg.org/dnkl/foot/pulls/1448
|
[1448]: https://codeberg.org/dnkl/foot/pulls/1448
|
||||||
[1474]: https://codeberg.org/dnkl/foot/pulls/1474
|
[1474]: https://codeberg.org/dnkl/foot/pulls/1474
|
||||||
|
[1495]: https://codeberg.org/dnkl/foot/pulls/1495
|
||||||
|
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
|
||||||
39
config.c
39
config.c
|
|
@ -2912,7 +2912,7 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
config_override_t *overrides, bool errors_are_fatal,
|
config_override_t *overrides, bool errors_are_fatal,
|
||||||
bool as_server)
|
bool as_server)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = true;
|
||||||
enum fcft_capabilities fcft_caps = fcft_capabilities();
|
enum fcft_capabilities fcft_caps = fcft_capabilities();
|
||||||
|
|
||||||
*conf = (struct config) {
|
*conf = (struct config) {
|
||||||
|
|
@ -3106,45 +3106,40 @@ config_load(struct config *conf, const char *conf_path,
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
LOG_AND_NOTIFY_ERRNO("%s: failed to open", conf_path);
|
LOG_AND_NOTIFY_ERRNO("%s: failed to open", conf_path);
|
||||||
ret = !errors_are_fatal;
|
ret = !errors_are_fatal;
|
||||||
goto out;
|
} else {
|
||||||
|
conf_file.path = xstrdup(conf_path);
|
||||||
|
conf_file.fd = fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf_file.path = xstrdup(conf_path);
|
|
||||||
conf_file.fd = fd;
|
|
||||||
} else {
|
} else {
|
||||||
conf_file = open_config();
|
conf_file = open_config();
|
||||||
if (conf_file.fd < 0) {
|
if (conf_file.fd < 0) {
|
||||||
LOG_WARN("no configuration found, using defaults");
|
LOG_WARN("no configuration found, using defaults");
|
||||||
ret = !errors_are_fatal;
|
ret = !errors_are_fatal;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xassert(conf_file.path != NULL);
|
if (conf_file.path && conf_file.fd >= 0) {
|
||||||
xassert(conf_file.fd >= 0);
|
LOG_INFO("loading configuration from %s", conf_file.path);
|
||||||
LOG_INFO("loading configuration from %s", conf_file.path);
|
|
||||||
|
|
||||||
FILE *f = fdopen(conf_file.fd, "r");
|
FILE *f = fdopen(conf_file.fd, "r");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
LOG_AND_NOTIFY_ERRNO("%s: failed to open", conf_file.path);
|
LOG_AND_NOTIFY_ERRNO("%s: failed to open", conf_file.path);
|
||||||
ret = !errors_are_fatal;
|
ret = !errors_are_fatal;
|
||||||
goto out;
|
} else {
|
||||||
|
if (!parse_config_file(f, conf, conf_file.path, errors_are_fatal))
|
||||||
|
ret = !errors_are_fatal;
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parse_config_file(f, conf, conf_file.path, errors_are_fatal) ||
|
if (!config_override_apply(conf, overrides, errors_are_fatal))
|
||||||
!config_override_apply(conf, overrides, errors_are_fatal))
|
|
||||||
{
|
|
||||||
ret = !errors_are_fatal;
|
ret = !errors_are_fatal;
|
||||||
} else
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
conf->colors.use_custom.selection =
|
conf->colors.use_custom.selection =
|
||||||
conf->colors.selection_fg >> 24 == 0 &&
|
conf->colors.selection_fg >> 24 == 0 &&
|
||||||
conf->colors.selection_bg >> 24 == 0;
|
conf->colors.selection_bg >> 24 == 0;
|
||||||
|
|
||||||
out:
|
|
||||||
if (ret && conf->fonts[0].count == 0) {
|
if (ret && conf->fonts[0].count == 0) {
|
||||||
struct config_font font;
|
struct config_font font;
|
||||||
if (!config_font_parse("monospace", &font)) {
|
if (!config_font_parse("monospace", &font)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue