summaryrefslogtreecommitdiff
path: root/liblightdm-gobject
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2012-06-14 16:37:36 +1200
committerRobert Ancell <robert.ancell@canonical.com>2012-06-14 16:37:36 +1200
commitcb980122ba77235b908350a0f7496fa9e855a50d (patch)
tree0d971e7bea823c921d34dfd6199e2b5f570ad587 /liblightdm-gobject
parent50b8912297a3f7bf09dccf06c1e13944cf3a70f7 (diff)
parent0c45755134f06f7098f6576a09a718c1d2e6d50d (diff)
downloadlightdm-cb980122ba77235b908350a0f7496fa9e855a50d.tar.gz
Use xsession directory from lightdm.conf in liblightdm
Diffstat (limited to 'liblightdm-gobject')
-rw-r--r--liblightdm-gobject/Makefile.am1
-rw-r--r--liblightdm-gobject/session.c31
2 files changed, 30 insertions, 2 deletions
diff --git a/liblightdm-gobject/Makefile.am b/liblightdm-gobject/Makefile.am
index 93f190b8..8c0ce526 100644
--- a/liblightdm-gobject/Makefile.am
+++ b/liblightdm-gobject/Makefile.am
@@ -4,6 +4,7 @@ liblightdm_gobject_1_la_LDFLAGS = -export-symbols-regex \^lightdm_.*
liblightdm_gobject_1_la_LIBADD = $(LIBLIGHTDM_GOBJECT_LIBS)
liblightdm_gobject_1_la_CFLAGS = $(LIBLIGHTDM_GOBJECT_CFLAGS) \
$(WARN_CFLAGS) \
+ -DCONFIG_DIR=\"$(sysconfdir)/lightdm\" \
-DXSESSIONS_DIR=\"$(datadir)/xsessions\"
mainheader_HEADERS = lightdm.h
diff --git a/liblightdm-gobject/session.c b/liblightdm-gobject/session.c
index 7eb33373..603ddb7f 100644
--- a/liblightdm-gobject/session.c
+++ b/liblightdm-gobject/session.c
@@ -110,17 +110,43 @@ static void
update_sessions (void)
{
GDir *directory;
+ gboolean result;
GError *error = NULL;
+ GKeyFile *config_key_file = NULL;
+ gchar *config_path = NULL;
+ gchar *xsessions_dir = g_strdup (XSESSIONS_DIR);
+
if (have_sessions)
return;
- directory = g_dir_open (XSESSIONS_DIR, 0, &error);
+ config_path = g_build_filename (CONFIG_DIR, "lightdm.conf", NULL);
+ config_key_file = g_key_file_new ();
+ result = g_key_file_load_from_file (config_key_file, config_path, G_KEY_FILE_NONE, &error);
+ if (error)
+ g_warning ("Failed to open configuration file: %s", error->message);
+ g_clear_error (&error);
+ if (result)
+ {
+ gchar *xd_value = g_key_file_get_string (config_key_file, "LightDM", "xsessions-directory", NULL);
+ if (xd_value)
+ {
+ g_free (xsessions_dir);
+ xsessions_dir = xd_value;
+ }
+ }
+ g_key_file_free (config_key_file);
+ g_free (config_path);
+
+ directory = g_dir_open (xsessions_dir, 0, &error);
if (error)
g_warning ("Failed to open sessions directory: %s", error->message);
g_clear_error (&error);
if (!directory)
+ {
+ g_free (xsessions_dir);
return;
+ }
while (TRUE)
{
@@ -136,7 +162,7 @@ update_sessions (void)
if (!g_str_has_suffix (filename, ".desktop"))
continue;
- path = g_build_filename (XSESSIONS_DIR, filename, NULL);
+ path = g_build_filename (xsessions_dir, filename, NULL);
key_file = g_key_file_new ();
result = g_key_file_load_from_file (key_file, path, G_KEY_FILE_NONE, &error);
@@ -163,6 +189,7 @@ update_sessions (void)
}
g_dir_close (directory);
+ g_free (xsessions_dir);
have_sessions = TRUE;
}