return 0;
}
+
+char *
+config_file_path(const char *name)
+{
+ const char dotconf[] = "/.config/";
+ const char *config_dir;
+ const char *home_dir;
+ char *path;
+ size_t size;
+
+ config_dir = getenv("XDG_CONFIG_HOME");
+ if (!config_dir) {
+ fprintf(stderr, "XDG_CONFIG_HOME is not set,"
+ " falling back to $HOME/.config\n");
+
+ home_dir = getenv("HOME");
+ if (!home_dir) {
+ fprintf(stderr, "HOME is not set, using cwd.\n");
+ return strdup(name);
+ }
+
+ size = strlen(home_dir) + sizeof dotconf + strlen(name);
+ path = malloc(size);
+ if (!path)
+ return NULL;
+
+ snprintf(path, size, "%s%s%s", home_dir, dotconf, name);
+ return path;
+ }
+
+ size = strlen(config_dir) + 1 + strlen(name) + 1;
+ path = malloc(size);
+ if (!path)
+ return NULL;
+
+ snprintf(path, size, "%s/%s", config_dir, name);
+ return path;
+}
int main(int argc, char *argv[])
{
struct desktop desktop;
+ char *config_file;
desktop.display = display_create(&argc, &argv, NULL);
if (desktop.display == NULL) {
desktop.panel = panel_create(desktop.display);
- parse_config_file("wayland-desktop-shell.ini",
+ config_file = config_file_path("wayland-desktop-shell.ini");
+ parse_config_file(config_file,
config_sections, ARRAY_LENGTH(config_sections),
&desktop);
+ free(config_file);
printf("panel color: %08x\n", key_panel_color);