fix: necessary code changes for nix configurability

This commit is contained in:
2025-07-06 05:13:09 +02:00
parent be6e039a9b
commit 689c962cc9
3 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,11 @@
#ifndef MACROSH_ #ifndef MACROSH_
#define MACROSH_ #define MACROSH_
// More like constants but I'm not making yet another header file just for this
#ifndef LIDM_CONF_PATH
#define LIDM_CONF_PATH "/etc/lidm.ini"
#endif
// Do we just replace the compiler with clang?? // Do we just replace the compiler with clang??
#if defined(__clang__) #if defined(__clang__)
#define NULLABLE _Nullable #define NULLABLE _Nullable

View File

@@ -12,6 +12,7 @@
#include "config.h" #include "config.h"
#include "desktop.h" #include "desktop.h"
#include "log.h" #include "log.h"
#include "macros.h"
#include "util.h" #include "util.h"
#define UPPER_HALF_BYTE 4 #define UPPER_HALF_BYTE 4
@@ -241,9 +242,8 @@ int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
FILE* fd = fopen(path, "r"); FILE* fd = fopen(path, "r");
if (fd == NULL) { if (fd == NULL) {
log_perror("fopen"); log_perror("fopen");
log_printf( log_printf(" [I] No config, place one at " LIDM_CONF_PATH
" [I] No config, place one at /etc/lidm.ini or set the LIDM_CONF " " or set the LIDM_CONF env variable");
"env variable");
return 0; // Its fine now anyways return 0; // Its fine now anyways
} }

View File

@@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {
// Copy // Copy
struct config config = DEFAULT_CONFIG; struct config config = DEFAULT_CONFIG;
char* conf_override = getenv("LIDM_CONF"); char* conf_override = getenv("LIDM_CONF");
char* conf_path = conf_override ? conf_override : "/etc/lidm.ini"; char* conf_path = conf_override ? conf_override : LIDM_CONF_PATH;
if (parse_config(&config, conf_path) != 0) { if (parse_config(&config, conf_path) != 0) {
(void)fputs("error parsing config\n", stderr); (void)fputs("error parsing config\n", stderr);
return 1; return 1;