summaryrefslogtreecommitdiff
path: root/daemon/gdm-launch-environment.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo@endlessm.com>2018-11-05 08:42:12 -0800
committerRay Strode <halfline@gmail.com>2021-07-09 17:03:59 +0000
commit3096ed862717103e87b78afd94e92dc461e30509 (patch)
tree91e4d06f748d35b149b15cffb07ce3c1bcb52a6b /daemon/gdm-launch-environment.c
parent48d92c7e9ae12fd203d1ac120467bf2b9c934331 (diff)
downloadgdm-3096ed862717103e87b78afd94e92dc461e30509.tar.gz
launch-environment: Read XDG_DATA_DIRS from env.d for initial-setup
In the initial setup session we may need to run a Flatpak application; Flatpak requires XDG_DATA_DIRS to include its locations to work correctly, but that's not set at the moment for the initial-setup session. This commit borrows the code from GdmSessionWorker to read XDG_DATA_DIRS from gdm's env.d machinery for the initial-setup session as well.
Diffstat (limited to 'daemon/gdm-launch-environment.c')
-rw-r--r--daemon/gdm-launch-environment.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/daemon/gdm-launch-environment.c b/daemon/gdm-launch-environment.c
index feccf057..87a1c5ff 100644
--- a/daemon/gdm-launch-environment.c
+++ b/daemon/gdm-launch-environment.c
@@ -113,6 +113,23 @@ static void gdm_launch_environment_finalize (GObject
G_DEFINE_TYPE_WITH_PRIVATE (GdmLaunchEnvironment, gdm_launch_environment, G_TYPE_OBJECT)
+static char *
+get_var_cb (const char *var,
+ gpointer user_data)
+{
+ const char *value = g_hash_table_lookup (user_data, var);
+ return g_strdup (value);
+}
+
+static void
+load_env_func (const char *var,
+ const char *value,
+ gpointer user_data)
+{
+ GHashTable *environment = user_data;
+ g_hash_table_replace (environment, g_strdup (var), g_strdup (value));
+}
+
static GHashTable *
build_launch_environment (GdmLaunchEnvironment *launch_environment,
gboolean start_session)
@@ -159,15 +176,6 @@ build_launch_environment (GdmLaunchEnvironment *launch_environment,
g_strdup (g_getenv (optional_environment[i])));
}
- system_data_dirs = g_strjoinv (":", (char **) g_get_system_data_dirs ());
-
- g_hash_table_insert (hash,
- g_strdup ("XDG_DATA_DIRS"),
- g_strdup_printf ("%s:%s",
- DATADIR "/gdm/greeter",
- system_data_dirs));
- g_free (system_data_dirs);
-
if (launch_environment->priv->x11_authority_file != NULL)
g_hash_table_insert (hash, g_strdup ("XAUTHORITY"), g_strdup (launch_environment->priv->x11_authority_file));
@@ -218,6 +226,24 @@ build_launch_environment (GdmLaunchEnvironment *launch_environment,
g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
+ /* Now populate XDG_DATA_DIRS from env.d if we're running initial setup; this allows
+ * e.g. Flatpak apps to be recognized by gnome-shell.
+ */
+ if (g_strcmp0 (launch_environment->priv->session_mode, INITIAL_SETUP_SESSION_MODE) == 0)
+ gdm_load_env_d (load_env_func, get_var_cb, hash);
+
+ /* Prepend our own XDG_DATA_DIRS value */
+ system_data_dirs = g_strdup (g_hash_table_lookup (hash, "XDG_DATA_DIRS"));
+ if (!system_data_dirs)
+ system_data_dirs = g_strjoinv (":", (char **) g_get_system_data_dirs ());
+
+ g_hash_table_insert (hash,
+ g_strdup ("XDG_DATA_DIRS"),
+ g_strdup_printf ("%s:%s",
+ DATADIR "/gdm/greeter",
+ system_data_dirs));
+ g_free (system_data_dirs);
+
return hash;
}