config: add 'server_socket_path' and set a default value

This commit is contained in:
Daniel Eklöf 2019-12-14 12:59:06 +01:00
parent 6ef65058cf
commit 6d31bd63be
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 16 additions and 0 deletions

View file

@ -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);
}

View file

@ -34,6 +34,8 @@ struct config {
} cursor;
size_t render_worker_count;
char *server_socket_path;
};
bool config_load(struct config *conf);