1
0
mirror of https://github.com/emersion/kanshi synced 2024-09-18 09:51:36 +02:00

Use XDG_CONFIG_HOME

This commit is contained in:
Simon Ser 2019-05-30 23:37:44 +03:00
parent 1cbfcca0ca
commit 4f0ee6a165

19
main.c
View File

@ -1,9 +1,26 @@
#define _POSIX_C_SOURCE 1
#include <limits.h>
#include <stdlib.h>
#include "parser.h"
int main(int argc, char *argv[]) {
struct kanshi_config *config = parse_config("/home/simon/.config/kanshi/config");
const char config_filename[] = "kanshi/config";
char config_path[PATH_MAX];
const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
const char *home = getenv("HOME");
if (xdg_config_home != NULL) {
snprintf(config_path, sizeof(config_path), "%s/%s",
xdg_config_home, config_filename);
} else if (home != NULL) {
snprintf(config_path, sizeof(config_path), "%s/.config/%s",
home, config_filename);
} else {
fprintf(stderr, "HOME not set\n");
return EXIT_FAILURE;
}
struct kanshi_config *config = parse_config(config_path);
if (config == NULL) {
return EXIT_FAILURE;
}