aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-06-03 03:22:35 +0200
committerDavid Moc <personal@cdatgoose.org>2026-06-03 03:22:35 +0200
commitc1ccd38b31d722c843ab311338e2b8d1905eb8f8 (patch)
treedcdac7a4d3d3700cf27129012f488a701043f671 /src
parentc6d44836fd8ed1442e01825cb0f9f97e7bf11515 (diff)
Default config and fixed installing.
Diffstat (limited to 'src')
-rw-r--r--src/main.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 191a159..b3e7af4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,10 +3,12 @@
#include "font.h"
#include "media.h"
#include "render.h"
+#include "util.h"
#include <GLFW/glfw3.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#define WINDOW_WIDTH 1000
@@ -24,6 +26,9 @@ static void print_usage(const char *argv0) {
fprintf(stderr, "env:\n");
fprintf(stderr, " ECEX_FONT=/path/to/font.ttf\n");
fprintf(stderr, " ECEX_INCLUDE=/path/to/ecex/include\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "default config:\n");
+ fprintf(stderr, " ~/.config/ecex/ecexrc.c\n");
}
static int parse_args(int argc,
@@ -66,6 +71,24 @@ static const char *select_font_path(ecex_t *ed, const char *font_path_arg) {
return font_choose_path(NULL);
}
+static const char *find_default_config_path(void) {
+ static char path[4096];
+
+ const char *xdg_config = getenv("XDG_CONFIG_HOME");
+ if (xdg_config && xdg_config[0]) {
+ snprintf(path, sizeof(path), "%s/ecex/ecexrc.c", xdg_config);
+ if (ecex_file_exists(path)) return path;
+ }
+
+ const char *home = getenv("HOME");
+ if (home && home[0]) {
+ snprintf(path, sizeof(path), "%s/.config/ecex/ecexrc.c", home);
+ if (ecex_file_exists(path)) return path;
+ }
+
+ return NULL;
+}
+
int main(int argc, char **argv) {
const char *config_path = NULL;
const char *font_path_arg = NULL;
@@ -81,6 +104,10 @@ int main(int argc, char **argv) {
return 1;
}
+ if (!config_path) {
+ config_path = find_default_config_path();
+ }
+
if (config_path) {
if (ecex_load_c_config(ed, config_path) != 0) {
fprintf(stderr, "ecex: continuing without config\n");