feat: modernize config

- config now is more toml like
- no need to declare all fields, it implements defaults
- no yanderedev code, introspection babbyyy 😎
- desktop and config files parser semi-unification
- misc tweaks all over (mainly allocation failures handling)
This commit is contained in:
2025-06-13 14:05:19 +02:00
parent 3480393a66
commit 5174f0b2bf
13 changed files with 480 additions and 304 deletions

View File

@@ -14,6 +14,7 @@
#include "util.h"
int main(int argc, char* argv[]) {
// Logger
char* log_output = getenv("LIDM_LOG");
if (log_output) {
FILE* log_fd = fopen(log_output, "w");
@@ -26,17 +27,17 @@ int main(int argc, char* argv[]) {
log_init(log_fd);
}
// Chvt
if (argc == 2) chvt_str(argv[1]);
struct config config = default_config;
char* conf_override = getenv("LIDM_CONF");
struct config* config =
parse_config(conf_override == NULL ? "/etc/lidm.ini" : conf_override);
if (config == NULL) {
// NOLINT(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling)
char* conf_path = conf_override ? conf_override : "/etc/lidm.ini";
if (parse_config(&config, conf_path) != 0) {
(void)fputs("error parsing config\n", stderr);
return 1;
}
setup(*config);
setup(&config);
struct Vector users = get_human_users();
struct Vector sessions = get_avaliable_sessions();