summaryrefslogtreecommitdiff
path: root/libgdm
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2018-08-04 15:26:53 +0200
committerRay Strode <halfline@gmail.com>2018-08-27 13:33:11 +0000
commit385b9c22b638793403a734a5e3bf34406491c0e6 (patch)
tree3a40c499abc306b67ed16da8387ac8562b8202e9 /libgdm
parent68e764b9b93fb1b610e0c200acb8e3558fdde79c (diff)
downloadgdm-385b9c22b638793403a734a5e3bf34406491c0e6.tar.gz
Search sessions in XDG_DATA_DIRS
Diffstat (limited to 'libgdm')
-rw-r--r--libgdm/gdm-sessions.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c
index 8bf7bd75..7badafe1 100644
--- a/libgdm/gdm-sessions.c
+++ b/libgdm/gdm-sessions.c
@@ -215,6 +215,9 @@ collect_sessions_from_directory (const char *dirname)
static void
collect_sessions (void)
{
+ GArray *xorg_search_array = NULL;
+ GArray *wayland_search_array = NULL;
+ gchar *session_dir = NULL;
int i;
const char *xorg_search_dirs[] = {
"/etc/X11/sessions/",
@@ -224,11 +227,31 @@ collect_sessions (void)
NULL
};
+ xorg_search_array = g_array_new (TRUE, TRUE, sizeof (char *));
+
+ const gchar * const *system_data_dirs = g_get_system_data_dirs ();
+
+ for (i = 0; system_data_dirs[i]; i++) {
+ session_dir = g_build_filename (system_data_dirs[i], "xsessions", NULL);
+ g_array_append_val (xorg_search_array, session_dir);
+ }
+
+ g_array_append_vals (xorg_search_array, xorg_search_dirs, G_N_ELEMENTS (xorg_search_dirs));
+
#ifdef ENABLE_WAYLAND_SUPPORT
const char *wayland_search_dirs[] = {
DATADIR "/wayland-sessions/",
NULL
};
+
+ wayland_search_array = g_array_new (TRUE, TRUE, sizeof (char *));
+
+ for (i = 0; system_data_dirs[i]; i++) {
+ session_dir = g_build_filename (system_data_dirs[i], "wayland-sessions", NULL);
+ g_array_append_val (wayland_search_array, session_dir);
+ }
+
+ g_array_append_vals (wayland_search_array, wayland_search_dirs, G_N_ELEMENTS (wayland_search_dirs));
#endif
if (gdm_available_sessions_map == NULL) {
@@ -236,20 +259,25 @@ collect_sessions (void)
g_free, (GDestroyNotify)gdm_session_file_free);
}
- for (i = 0; xorg_search_dirs [i] != NULL; i++) {
- collect_sessions_from_directory (xorg_search_dirs [i]);
+ for (i = 0; i < xorg_search_array->len; i++) {
+ collect_sessions_from_directory (g_array_index (xorg_search_array, gchar*, i));
}
+ g_array_free (xorg_search_array, TRUE);
+
#ifdef ENABLE_WAYLAND_SUPPORT
#ifdef ENABLE_USER_DISPLAY_SERVER
if (g_getenv ("WAYLAND_DISPLAY") == NULL && g_getenv ("RUNNING_UNDER_GDM") != NULL) {
+ g_array_free (wayland_search_array, TRUE);
return;
}
#endif
- for (i = 0; wayland_search_dirs [i] != NULL; i++) {
- collect_sessions_from_directory (wayland_search_dirs [i]);
+ for (i = 0; i < wayland_search_array->len; i++) {
+ collect_sessions_from_directory (g_array_index (wayland_search_array, gchar*, i));
}
+
+ g_array_free (wayland_search_array, TRUE);
#endif
}