From 8bb5a72064f92e05518aacb9d756c49230ecf7e8 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 24 Nov 2013 01:31:36 +0100 Subject: [PATCH] Also look for applications in "~/.local/share" if XDG_DATA_HOME is not set --- src/applets/main.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/applets/main.c b/src/applets/main.c index 13b274a..93c81f2 100644 --- a/src/applets/main.c +++ b/src/applets/main.c @@ -497,6 +497,7 @@ static void _clicked_position_menu(GtkMenu * menu, gint * x, gint * y, /* on_idle */ +static void _idle_home(Main * main); static void _idle_path(Main * main, char const * path); static void _idle_path_do(Main * main, char const * path); static gint _idle_apps_compare(gconstpointer a, gconstpointer b); @@ -531,13 +532,38 @@ static gboolean _on_idle(gpointer data) } else _idle_path(main, DATADIR); - /* FIXME fallback to "$HOME/.local/share" if not set */ - if((path = getenv("XDG_DATA_HOME")) != NULL && strlen(path) > 0) - _idle_path(main, path); + _idle_home(main); g_timeout_add(1000, _on_timeout, main); return FALSE; } +static void _idle_home(Main * main) +{ + char const fallback[] = ".local/share"; + char const * path; + char const * homedir; + size_t len; + char * p; + + /* FIXME fallback to "$HOME/.local/share" if not set */ + if((path = getenv("XDG_DATA_HOME")) != NULL && strlen(path) > 0) + { + _idle_path(main, path); + return; + } + if((homedir = getenv("HOME")) == NULL) + homedir = g_get_home_dir(); + len = strlen(homedir) + 1 + sizeof(fallback); + if((p = malloc(len)) == NULL) + { + main->helper->error(NULL, homedir, 1); + return; + } + snprintf(p, len, "%s/%s", homedir, fallback); + _idle_path(main, p); + free(p); +} + static void _idle_path(Main * main, char const * path) { const char applications[] = "/applications";