From 6d31bd63be1f5288f0bbe8ece6e264b71c92c036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 14 Dec 2019 12:59:06 +0100 Subject: [PATCH] config: add 'server_socket_path' and set a default value --- config.c | 14 ++++++++++++++ config.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/config.c b/config.c index 6f2d0bf8..55e82b46 100644 --- a/config.c +++ b/config.c @@ -450,6 +450,18 @@ err: return false; } +static char * +get_server_socket_path(void) +{ + const char *xdg_runtime = getenv("XDG_RUNTIME_DIR"); + if (xdg_runtime == NULL) + return strdup("/tmp/foot.sock"); + + char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot.sock") + 1); + sprintf(path, "%s/foot.sock", xdg_runtime); + return path; +} + bool config_load(struct config *conf) { @@ -498,6 +510,7 @@ config_load(struct config *conf) }, .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), + .server_socket_path = get_server_socket_path(), }; char *path = get_config_path(); @@ -531,4 +544,5 @@ config_free(struct config conf) free(conf.term); free(conf.shell); tll_free_and_free(conf.fonts, free); + free(conf.server_socket_path); } diff --git a/config.h b/config.h index 0db130ad..4e7086d7 100644 --- a/config.h +++ b/config.h @@ -34,6 +34,8 @@ struct config { } cursor; size_t render_worker_count; + + char *server_socket_path; }; bool config_load(struct config *conf);