summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clients/config.c43
-rw-r--r--clients/desktop-shell.c5
-rw-r--r--clients/window.h3
-rw-r--r--configure.ac2
4 files changed, 8 insertions, 45 deletions
diff --git a/clients/config.c b/clients/config.c
index 5680d50..0b69e58 100644
--- a/clients/config.c
+++ b/clients/config.c
@@ -27,6 +27,9 @@
#include <window.h>
+#include <basedir.h>
+#include <basedir_fs.h>
+
static int
handle_key(const struct config_key *key, const char *value)
{
@@ -80,9 +83,10 @@ parse_config_file(const char *path,
const struct config_section *current = NULL;
int i;
- fp = fopen(path, "r");
+ fp = xdgConfigOpen(path, "r", NULL);
if (fp == NULL) {
- fprintf(stderr, "couldn't open %s\n", path);
+ fprintf(stderr, "couldn't open $XDG_CONFIG_{DIRS,HOME}/%s\n",
+ path);
return -1;
}
@@ -135,38 +139,3 @@ parse_config_file(const char *path,
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) {
- 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;
-}
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c
index adf3a5c..002e97b 100644
--- a/clients/desktop-shell.c
+++ b/clients/desktop-shell.c
@@ -514,7 +514,6 @@ launcher_section_done(void *data)
int main(int argc, char *argv[])
{
struct desktop desktop = { 0 };
- char *config_file;
desktop.unlock_task.run = unlock_dialog_finish;
@@ -532,11 +531,9 @@ int main(int argc, char *argv[])
desktop.panel = panel_create(desktop.display);
- config_file = config_file_path("wayland-desktop-shell.ini");
- parse_config_file(config_file,
+ parse_config_file("wayland/desktop-shell.ini",
config_sections, ARRAY_LENGTH(config_sections),
&desktop);
- free(config_file);
desktop_shell_set_panel(desktop.shell,
window_get_wl_surface(desktop.panel->window));
diff --git a/clients/window.h b/clients/window.h
index bad1e60..40bf102 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -346,7 +346,4 @@ parse_config_file(const char *path,
const struct config_section *sections, int num_sections,
void *data);
-char *
-config_file_path(const char *name);
-
#endif
diff --git a/configure.ac b/configure.ac
index 60d5f6b..b2b1e4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,7 +104,7 @@ AM_CONDITIONAL(BUILD_CLIENTS, test x$enable_clients == xyes)
if test x$enable_clients == xyes; then
AC_DEFINE([BUILD_CLIENTS], [1], [Build the Wayland clients])
- PKG_CHECK_MODULES(CLIENT, [wayland-client wayland-egl egl >= 7.10 gl cairo >= 1.10.0 gdk-pixbuf-2.0 glib-2.0 gobject-2.0 xkbcommon])
+ PKG_CHECK_MODULES(CLIENT, [wayland-client wayland-egl egl >= 7.10 gl cairo >= 1.10.0 gdk-pixbuf-2.0 glib-2.0 gobject-2.0 xkbcommon libxdg-basedir])
PKG_CHECK_MODULES(POPPLER, [poppler-glib gdk-2.0 gio-2.0],
[have_poppler=yes], [have_poppler=no])